C99 and decimal floating-point

C99 and decimal floating-point

I am trying to compile a C99 program that uses decimal floating-point, but get errors.

Hardware: Intel Pentium 4 in IA-32 mode

O. S.: Linux: Fedora Core 10

Compiler: Intel C Compiler Pro IA-32, Version 11.1, Build 2010/04/14

Command line: icc -std=c99 -fp-model strict -O0 test.c

where test.c is these two lines:
#define __STDC_WANT_DEC_FP__
#include

The error I get is: .../math.h(1172): error: identifier "_Decimal32" is undefined
extern _Decimal32 acosd32(_Decimal32 x);

It appears the -std=c99 disables decimal floating-point.

Aside: Your should have at line 1171:
#if (defined __STDC_WANT_DEC_FP__) && (defined __STDC_DEC_FP__)

So, what command line options do I need to enable decimal FP, along with c99?

8 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

The decimal floating point library is an option in the build of recent versions of gcc. If it were enabled, it would show up in gcc -v configuration options. I doubt that it is tested in combination with icc. There are more tests of it in the current gcc test suite than in earlier versions.
You could build and test gcc yourself with the decimal library and then check whether the decimal library test cases also work with icc.

Hi tvdeman,

I've sent this issue to our engineering team for further investigation. I'll let you know when I have an update regarding it.

Thanks,
Feilong

Hi tydeman,

Our engineering team thinks that the behavior is desired in c99 mode. Decimal floating point is not part of the C99 standard (but neither are lots of other things we allow in C99 mode). I tested with gcc 4.5. See below.

# gcc -c dfp.c
# gcc -c -std=c99 dfp.c
dfp.c: In function main:
dfp.c:7:2: error: _Decimal32 undeclared (first use in this function)
dfp.c:7:2: note: each undeclared identifier is reported only once for each funct
dfp.c:7:13: error: expected ; before in1
dfp.c:10:2: error: in1 undeclared (first use in this function)
dfp.c:11:2: error: in2 undeclared (first use in this function)
dfp.c:12:2: error: out1 undeclared (first use in this function)
dfp.c:13:2: error: out2 undeclared (first use in this function)
dfp.c:18:2: warning: implicit declaration of function sind32
# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.5.0/lto-wr
Target: x86_64-unknown-linux-gnu
Configured with: ./configure
Thread model: posix
gcc version 4.5.0 (GCC)
#

Thanks,
Feilong

Decimal floating-point (DFP) is defined as being built on top of C99. See the document WG14 N1312.
In particular, the function samequantumd64() returns a _Bool. _Bool is a feature of C99. _Bool
is not part of C89/C90/C95. So, there needs to be a way to tell the compiler I want both C99 and
DFP.

gcc -std=gnu99 ...
tells gcc to give me C99 with gcc extensions (which includes DFP).

Our developer posted an update regarding this feature request:

It is expected that the Decimal Floating-Point types in C++ would be implemented via C++ classes (header and library). The C++ standard docs have been proposed by IBM and arehttp://open-std.org/JTC1/SC22/WG21/docs/papers/2008/n2732.pdf
------end of update-----

I'll let you know when I have more updates.

Thanks,
Feilong

Engineering team has implemented this for 13.0 compiler. I'll let you know when 13.0 compiler that contains DFP support for C++ is available for download.

Thank you.

Feilong

13.0 compiler is available for download at . Note that you need gcc 4.5 or later, in order to use DFP in C++.

> cat try.cpp
#include
#include

int main() {
std::decimal::decimal32 d = 4.7df;
std::cout << decimal_to_long_double(d) << std::endl;
return 0;
}

> icpc try.cpp && ./a.out
4.7
>

Thanks,
Feilong

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen