4 The exact set of features available when you compile a source file
5 is controlled by which "feature test macros" you define.
7 If you compile your programs using `gcc -ansi', you get only the
8 ANSI C library features, unless you explicitly request additional
9 features by defining one or more of the feature macros. *Note GNU CC
10 Command Options: (gcc.info)Invoking GCC, for more information about GCC
13 You should define these macros by using `#define' preprocessor
14 directives at the top of your source code files. These directives
15 *must* come before any `#include' of a system header file. It is best
16 to make them the very first thing in the file, preceded only by
17 comments. You could also use the `-D' option to GCC, but it's better
18 if you make the source files indicate their own meaning in a
21 - Macro: _POSIX_SOURCE
22 If you define this macro, then the functionality from the POSIX.1
23 standard (IEEE Standard 1003.1) is available, as well as all of the
26 - Macro: _POSIX_C_SOURCE
27 If you define this macro with a value of `1', then the
28 functionality from the POSIX.1 standard (IEEE Standard 1003.1) is
29 made available. If you define this macro with a value of `2',
30 then both the functionality from the POSIX.1 standard and the
31 functionality from the POSIX.2 standard (IEEE Standard 1003.2) are
32 made available. This is in addition to the ANSI C facilities.
35 If you define this macro, functionality derived from 4.3 BSD Unix
36 is included as well as the ANSI C, POSIX.1, and POSIX.2 material.
38 Some of the features derived from 4.3 BSD Unix conflict with the
39 corresponding features specified by the POSIX.1 standard. If this
40 macro is defined, the 4.3 BSD definitions take precedence over the
43 Due to the nature of some of the conflicts between 4.3 BSD and
44 POSIX.1, you need to use a special "BSD compatibility library"
45 when linking programs compiled for BSD compatibility. This is
46 because some functions must be defined in two different ways, one
47 of them in the normal C library, and one of them in the
48 compatibility library. If your program defines `_BSD_SOURCE', you
49 must give the option `-lbsd-compat' to the compiler or linker when
50 linking the program, to tell it to find functions in this special
51 compatibility library before looking for them in the normal C
55 If you define this macro, functionality derived from SVID is
56 included as well as the ANSI C, POSIX.1, POSIX.2, and X/Open
59 - Macro: _XOPEN_SOURCE
60 If you define these macro, functionality described in the X/Open
61 Portability Guide is included. This is an superset of the POSIX.1
62 and POSIX.2 functionality and in fact `_POSIX_SOURCE' and
63 `_POSIX_C_SOURCE' get automatically be defined.
65 But as the great unifaction of all Unices there is also
66 functionality only available in BSD and SVID is included.
68 If the macro `_XOPEN_SOURCE_EXTENDED' is also defined, even more
69 functionality is available. The extra functions will make all
70 functions available which are necessary for the X/Open Unix brand.
73 If you define this macro, everything is included: ANSI C, POSIX.1,
74 POSIX.2, BSD, SVID, X/Open, and GNU extensions. In the cases where
75 POSIX.1 conflicts with BSD, the POSIX definitions take precedence.
77 If you want to get the full effect of `_GNU_SOURCE' but make the
78 BSD definitions take precedence over the POSIX definitions, use
79 this sequence of definitions:
85 Note that if you do this, you must link your program with the BSD
86 compatibility library by passing the `-lbsd-compat' option to the
87 compiler or linker. *Note:* If you forget to do this, you may get
88 very strange errors at run time.
90 - Macro: _REENTRANT,_THREAD_SAFE
91 If you define one this macro, reentrant versions of several
92 functions get declared. Some of the functions are specified in
93 POSIX.1c but many others are only available on a few other systems
94 or are unique to GNU libc. The problem is that the
95 standardization of the thread safe C library interface still is
98 Unlike on some other systems no special version of the C library
99 must be used for linking. There is only one version but while
100 compiling this it must have been specified to compile as thread
103 We recommend you use `_GNU_SOURCE' in new programs. If you don't
104 specify the `-ansi' option to GCC and don't define any of these macros
105 explicitly, the effect is the same as defining `_POSIX_C_SOURCE' to 2
106 and `_POSIX_SOURCE', `_SVID_SOURCE', and `_BSD_SOURCE' to 1.
108 When you define a feature test macro to request a larger class of
109 features, it is harmless to define in addition a feature test macro for
110 a subset of those features. For example, if you define
111 `_POSIX_C_SOURCE', then defining `_POSIX_SOURCE' as well has no effect.
112 Likewise, if you define `_GNU_SOURCE', then defining either
113 `_POSIX_SOURCE' or `_POSIX_C_SOURCE' or `_SVID_SOURCE' as well has no
116 Note, however, that the features of `_BSD_SOURCE' are not a subset of
117 any of the other feature test macros supported. This is because it
118 defines BSD features that take precedence over the POSIX features that
119 are requested by the other macros. For this reason, defining
120 `_BSD_SOURCE' in addition to the other feature test macros does have an
121 effect: it causes the BSD features to take priority over the conflicting