Support for the POSIX, SVID, XPG, and BSD standards that were introduced previously mainly comes by way of the GNU C library (http://www.gnu.org/software/libc/).
Here is a list of macros supported by GCC that correspond to the previously discussed standards:
- _POSIX_SOURCE—Defining this enables POSIX.1 standard (IEEE Standard 1003.1) and all the ISO C facilities.
_POSIX_SOURCE is ignored if _POSIX_C_SOURCE is defined to be to a positive integer. - _POSIX_C_SOURCE—Define _POSIX_C_SOURCE to be greater than or equal to 1 to include functionality from the 1990 edition of the POSIX.1 standard (IEEE Standard 1003.1-1990).
Define _POSIX_C_SOURCE to be greater than or equal to 2 to include functionality from the 1992 edition of the POSIX.2 standard (IEEE Standard 1003.2-1992).
Define _POSIX_C_SOURCE to be greater than or equal to 199309L, and then the functionality from the 1993 edition of the POSIX.1b standard (IEEE Standard 1003.1b-1993) is made available. - _BSD_SOURCE—When defined, you have access to 4.3 BSD UNIX, ISO C, POSIX.1, and POSIX.2 functionality.
4.3 BSD definitions that conflict with POSIX.1 or POSIX.2 take precedence when this macro is defined. You must also link your application with -lbsd-compat so that the linker will resolve BSDdefined functions before searching for them in the normal C library. - _SVID_SOURCE—If defined, SVID-derived functionality is included, as well as that provided by ISO C, POSIX.1, POSIX.2, and X/Open standards.
- _XOPEN_SOURCE—Defining _XOPEN_SOURCE enables functions that are defined by the X/Open Portability Guide, in addition to those functions that are enabled by the _POSIX_SOURCE and _POSIX_C_SOURCE macros.
Defining _XOPEN_SOURCE as 500 includes _XOPEN_SOURCE functionality, and new functionality from the Single UNIX Specification, version 2. - _ISOC99_SOURCE—GNU libc is tracking the implementation of the new C99 standard, and by enabling the _ISOC99_SOURCE macro, you can 230 Chapter 5 Operating System Interfaces and Libraries make use of the features of this standard that have been implemented so far. Some of the features supported include C++ style comments and local variable declarations within conditional expressions (which appear within for, if, while, and switch statements). Furthermore, it prohibits explicit declarations of functions and variables that would default to int, and allows declarations of variables to occur anywhere within a block, as opposed to requiring the declarations before the first statement occurring in the block. This flag has no bearing on C++ code, as you might have guessed.
- _GNU_SOURCE—Defining this macro brings in everything described previously: ISO C89, ISO C99, POSIX.1, POSIX.2, BSD, SVID, and X/Open, and GNU-defined extensions. Should there be any conflicts with POSIX.1 and BSD, POSIX definitions take precedence over the BSD ones. You should avoid using this macro because the use of GNU extensions is inherently nonportable.



