why isn't __STDC__ being defined?

why isn't __STDC__ being defined?

Post by Frank Cusac » Sat, 28 Feb 1998 04:00:00



I'm having a problem with a header file believing that when gcc sometimes
incorrectly defines __STDC__ :

#if (defined(__STDC__) && (!defined(sun) || defined(__svr4__)))
...

ie, Solaris (which defines __svr4__) is OK, but sunos is not (I guess).
But gcc isn't defining __STDC__ !

From the non-bugs section of gcc's info (and I'm sure you gurus know
this:

     Currently, GNU CC defines `__STDC__' as long as you don't use
     `-traditional'.  This provides good results in practice.

     Programmers normally use conditionals on `__STDC__' to ask whether
     it is safe to use certain features of ANSI C, such as function
     prototypes or ANSI token concatenation.  Since plain `gcc' supports
     all the features of ANSI C, the correct answer to these questions
     is "yes".

     Some users try to use `__STDC__' to check for the availability of
     certain library facilities.  This is actually incorrect usage in
     an ANSI C program, because the ANSI C standard says that a
     conforming freestanding implementation should define `__STDC__'
     even though it does not have the library facilities.  `gcc -ansi
     -pedantic' is a conforming freestanding implementation, and it is
     therefore required to define `__STDC__', even though it does not
     come with an ANSI C library.

"gcc -ansi -pedantic ... required to define `__STDC__'".

Why then, do I get this:

bash-2.01# uname -a
SunOS foobar 5.6 Generic sun4m sparc SUNW,SPARCstation-10
bash-2.01# > a.c
bash-2.01# gcc -E -dM -ansi -pedantic a.c
#define __STRICT_ANSI__ 1
#define __GCC_NEW_VARARGS__ 1
#define __sparc 1
#define __svr4__ 1
#define __GNUC_MINOR__ 8
#define __sun 1
#define __sun__ 1
#define __unix 1
#define __unix__ 1
#define __SVR4 1
#define __GNUC__ 2
#define __sparc__ 1
bash-2.01#

(gcc-2.8.0; Solaris 2.6)

thanks for any help. (please cc: my email; I might miss your post)

--

 
 
 

1. Why are lots of typedefs not defined unless __STDC__ == 0 on Solaris 2.6?

I've been working on a program to display process trees dynamically to
work non-suid for Solaris 2.6 and up. I've been getting compiler
errors with egcs (the only compiler I have and have tried) because
lots of typedefs are missing such as for sigset_t and uint64_t (used
by "sys/procfs.h").

In /usr/include/sys/int_types.h we have
#if __STDC__ - 0 == 0 && !defined(_NO_LONGLONG)
typedef unsigned long long      uint64_t;
#endif

Looking at /usr/include/sys/signal.h we have:

#if defined(__EXTENSIONS__) || (__STDC__ - 0 == 0) || ...

Actually, the C-Preprocssor logic for sigset_t in sys/signal.h is
so complicated that I really have a hard time pinpointing why it is
not defined, other than knowing that you can #define __EXTENSIONS__ or
#define __STDC__ 0 and that will work.

Anyway, the question is what are the various meanings of the values of
__STDC__? Is this documented somewhere?

2. Help with the find command!

3. Why are lots of typedefs not defined unless __STDC__ == 0 on 2.6?

4. Easy text editor.

5. buffer_boundary isn't defined

6. Apache, old SCO, and starting CGI

7. I don't understand why this code isn't working

8. simple DNS Update from a machine with dynamic IP

9. samba's nmdb isn't working - why?

10. Why it's a good thing FreeBSD isn't as popular as Linux

11. Magic SysRq key isn't -- what am I doing wrong?

12. Why am I not 'Logged in' ?

13. Why there isn't negation operator for regular expression ?