Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

__STDC_IEC_559__ (defined or !defined ?)

196 views
Skip to first unread message

doriangray

unread,
Aug 17, 2010, 3:28:35 PM8/17/10
to
Hello everybody,

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

Alan Curry

unread,
Aug 17, 2010, 6:12:17 PM8/17/10
to
In article <vKmdnd2g1od-f_fR...@giganews.com>,

doriangray <nos...@email.net> wrote:
> "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;

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

doriangray

unread,
Aug 18, 2010, 4:56:17 AM8/18/10
to

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

Andrew Haley

unread,
Aug 18, 2010, 5:26:12 AM8/18/10
to

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.

doriangray

unread,
Aug 18, 2010, 5:39:33 AM8/18/10
to

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

Andrew Haley

unread,
Aug 18, 2010, 5:47:30 AM8/18/10
to
> 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?

I have no idea, sorry. I know zilch about Windows.

Andrew.

doriangray

unread,
Aug 18, 2010, 5:52:27 AM8/18/10
to

Thanks all the same.


--
Dorian

Keith Thompson

unread,
Aug 18, 2010, 2:32:20 PM8/18/10
to
Andrew Haley <andr...@littlepinkcloud.invalid> writes:
> doriangray <nos...@gmail.net> wrote:
[...]

>> 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?
>
> 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.

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"

doriangray

unread,
Aug 22, 2010, 6:54:13 AM8/22/10
to
Keith Thompson wrote:

> 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

Andrew Haley

unread,
Aug 22, 2010, 11:14:21 AM8/22/10
to

On my system:

$ rpm -qf /usr/include/limits.h
glibc-headers-2.11.2-1.x86_64

Andrew.

doriangray

unread,
Aug 22, 2010, 2:47:35 PM8/22/10
to

$ dpkg -S /usr/include/limits.h
libc6-dev: /usr/include/limits.h

thanx

--
Dorian

Richard Kettlewell

unread,
Aug 22, 2010, 6:14:02 PM8/22/10
to

The Glibc limits.h #includes the GCC one, and (at least here) vice
versa. So the answer is really "both".

--
http://www.greenend.org.uk/rjk/

0 new messages