>I am porting a library to a lot of operating systems (hp-ux, Solaris, aix,
>linux to name a few). there are lots of confusing defines around like
>_HPUX_SOURCE
>_POSIX_C_SOURCE
>_ALL_SOURCE
>_XOPEN_SOURCE
>POSIX_PTHREAD_SEMANTICS
>where I found no short and concise definition what they
>a) really mean (or are they really mean ;-)
>b) if they should be defined during compilation
>c) what value they should be defined to (if at all)
The *_SOURCE defines are called "Feature Test Macros". They control
what symbols are visible in the system's headers during compilation.
With a standards-compliant C compiler, if you don't define any of
these macros then all that will be visible are the symbols allowed
by the C standard. To use POSIX.1 symbols, for example, you must define
_POSIX_SOURCE before including any system headers. (A common way to
do this is to put -D_POSIX_SOURCE in the compiler flags in makefiles.)
If your Linux system has a recent version of glibc (recent = 2.1.x),
then do an "info libc" and find the node called "Feature Test Macros"
for an explanation of most of these macros. (Except that the last
paragraph of the part about _POSIX_C_SOURCE is incorrect - I have
reported it as a bug.) The ones it won't explain are _ALL_SOURCE and
_HPUX_SOURCE. These are used to make all the header symbols visible
on AIX and HP-UX respectively. (They are equivalent to _GNU_SOURCE
for glibc.)
I haven't come across POSIX_PTHREAD_SEMANTICS before. It must be
something specific to one of the systems you are using.
--