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:
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?
You could build and test gcc yourself with the decimal library and then check whether the decimal library test cases also work with icc.
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.
Configured with: ./configure
Thread model: posix
gcc version 4.5.0 (GCC)
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
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.
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.