The description of the problems I encountered is a little lengthy, so
I'll pose my question first, and the description will follow below :)
Question: Are there any issues to look out for when recompiling code
(either single-threaded or multi-threaded) with the following features
test macros enabled:
_POSIX_C_SOURCE, _XOPEN_SOURCE, and _XOPEN_SOURCE_EXTENDED ? Is there
any reason to use these if the code works w/o defining them [and doesn't
if they are defined :) ] ?
Here's my situation:
A number of places that talk about pthreads programming mention that the
code should be compiled with the macro _POSIX_C_SOURCE defined to be
equal to some value (199605L, if my memory serves me right).
I tried to rebuild my app with the macro defined on the compiler command
line, and as a result, certain bits of code no longer compiled. I
don't remember the exact errors right now, but it was something that
caused me to look in the system header files, and after some
experimenting, I got the code to compile again by defining two more
constants on the compiler command line (I saw the constants referenced
in the numerous #ifdefs in the headers).
At this point, my compiler's command line had the following added:
-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199605L
That had an unexpected side effect of changing a lot of the numbers
produced by the code to be, very consistently, 1 (one)... I became
suspicious and removed the "=1" part from the command line above, yielding
-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_POSIX_C_SOURCE=199605L
Rebuilding the code with the above definitions had the effect of causing
many of the numbers to become 270045908. Just like with the 1's, this
"result" was consistently reproducible.
Note that this problem happens even before the code gets to anything
thread-related, e.g., in the beginning of the prog, when a data file is
being read in and the data structures initialized; I've not yet traced
into the code deeply enough to isolate the first occurrence of the problem).
At this point, I figured I must be doing something wrong, and decided to
do some research; the only useful piece of information I found was the
description on the GNU libc page, but nothing there explained the wierd
side effects I was seeing, nor did I find anything else that was
relevant. Thus, I turn to this newsgroup and ask the question above.
Any information/suggestions would be most welcome.!
PS If it's relevant, this is happening on an SGI(IRIX 6.5) system.