POSIX_C_SOURCE

Malcolm Kay malcolm.kay at internode.on.net
Sun Aug 31 19:47:21 PDT 2003


On Sun, 31 Aug 2003 02:19, Garrett Wollman wrote:
> In article <20030830161813.GA28890 at twisted.net> you write:
> >Any chance that someone will finally commit the fixes to prevent the
> >POSIX_C_SOURCE warnings from showing up? I saw a number of posts on this
> >topic, but it still seems like it's not "officially committed"
> >
> >/usr/include/sys/cdefs.h:273: warning: `_POSIX_C_SOURCE' is not defined
> >/usr/include/sys/cdefs.h:279: warning: `_POSIX_C_SOURCE' is not defined
>
> The warnings are wrong,[1] so you should probably ask the GCC people
> about that.
>
> -GAWollman
>
> [1] That is to say, any identifier used in a preprocessor expression
> (after macro expansion) is defined to have a value of zero, and GCC
> should not be complaining about this.
>

The warnings are only wrong in your personal interpretation of right and 
wrong. Many gcc options generate warnings with legal C source and this is 
permitted by the C standard (whether or not it is controlled by a compiler 
option) provided it does not prevent generation of correct code.

The warning is true: that is _POSIX_C_SOURCE is not defined (and is evaluated
in an #if preprocessor statement).

The warning only appears when -Wundef option is used which relates 
specifically to this circumstance. GCC people surely cannot be criticised 
for an option that works precisely as documented.

No-one individually has it wrong.
The problem is one of incompatibility between the header files and the 
compiler options selected. Since the compiler options are probably set for a 
range of environments it is probably best to adapt the system header files to 
circumvent the difficulty.

Malcolm Kay



More information about the freebsd-stable mailing list