the "Further Notes" on gcc C99 status (http://gcc.gnu.org/c99status.html)
say:
"IEC 60559 is IEEE 754 floating point. This works if and only if
the hardware is perfectly compliant, but GCC does not define
__STDC_IEC_559__ or implement the associated standard pragmas;
[...]"
but the simple program:
#include <stdio.h>
int main(void) {
#ifdef __STDC_IEC_559__
puts("\n__STDC_IEC_559__ macro defined\n");
#else
puts("\n__STDC_IEC_559__ macro not defined\n");
#endif
return 0;
}
always performs the first 'puts' (gcc 4.4.4, Linux x86).
Can anyone tell me why?
Thanks!!
--
Dorian
gcc doesn't define it, but your libc does.
>#include <stdio.h>
stdio.h is included, it pulls in all the libc feature macros...
>int main(void) {
>
>#ifdef __STDC_IEC_559__
...and then you test __STDC_IEC_559__ so you don't distinguish
defined-by-compiler from defined-by-header. If you must know this
information, do the test before including any headers.
#ifdef __STDC_IEC_559__
#define COMPILER_DEFINED_IT "yes"
#else
#define COMPILER_DEFINED_IT "no"
#endif
#include <stdio.h>
int main(void)
{
puts("COMPILER_DEFINED_IT: " COMPILER_DEFINED_IT);
}
--
Alan Curry
Thanks. Now I have a doubt: which header is defined in gcc
and which one in glibc? I mean, everytime I include a header
am I actually calling glibc?
Sorry if it sounds trivial, I am a newbie.
--
Dorian
Sure. A conforming C implementation requires some sort of compiler
and a runtime library. In the GNU system, these are provided by two
separate projects: GNU CC and GNU libc.
http://gcc.gnu.org/
http://www.gnu.org/software/libc/
Oh, and some of the headers are actually provided by your operating
system's kernel.
Andrew.
Thank you. So this means that, for example,
under Windows, with same hardware and the gcc,
I could not have a IEEE 754 compliant system, am I right?
--
Dorian
I have no idea, sorry. I know zilch about Windows.
Andrew.
Thanks all the same.
--
Dorian
And some are provided by gcc itself, such as <limits.h>, <float.h>,
<stdarg.h>, and <iso646.h>.
--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
> And some are provided by gcc itself, such as<limits.h>,<float.h>,
> <stdarg.h>, and<iso646.h>.
but looking at the glibc manual I see there are <limits.h>
and <float.h>:
http://www.gnu.org/software/libc/manual/html_mono/libc.html#Data-Type-Measurements
So, when I include <limits.h>, am I including gcc's or glibc's header?
Is there a way to find it out?
--
Dorian
On my system:
$ rpm -qf /usr/include/limits.h
glibc-headers-2.11.2-1.x86_64
Andrew.
$ dpkg -S /usr/include/limits.h
libc6-dev: /usr/include/limits.h
thanx
--
Dorian
The Glibc limits.h #includes the GCC one, and (at least here) vice
versa. So the answer is really "both".