DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C language compilers

Feature test macros

There are two feature test macros that can be used with the compilation modes:


NOTE: _POSIX_SOURCE is the feature test macro for POSIX.1.

By default, neither feature test macro is defined. The default compilation mode is either -Xt or -Xa, depending on which compilation release is being used. With these default settings, every header makes visible all declarations and definitions.

As explained previously, the -Xc mode specifies visibility according to the C standard. When using -Xc with no feature test macros defined, the headers owned by the C standard (assert.h, ctype.h, errno.h, float.h, limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stddef.h, stdio.h, stdlib.h, string.h, and time.h) as well as the additional C99 headers (complex.h fenv.h inttypes.h iso646.h stdbool.h stdint.h tgmath.h wchar.h and wctype.h). are minimized.

When a feature test macro is defined in combination with the -Xc compilation mode, those headers owned by the associated [pseudo] standard are extended to make more declarations and definitions visible. For example, when using the -Xc compilation mode, if _POSIX_SOURCE is defined:

   cc -Xc -D_POSIX_SOURCE
then the statement
   FILE *fdopen(int, const char *);
would be present. However, it would not be present if the -Xc compilation mode is used without _POSIX_SOURCE defined.

Alternatively, when a feature test macro is defined in conjunction with -Xa or -Xt, the set of visible declarations and definitions in the associated headers are reduced. For example, <stdlib.h> will make getopt() visible if it is used with the -Xt compilation mode without _POSIX_SOURCE defined, but if _POSIX_SOURCE is defined, it will not be present.


NOTE: See The C Programming Language, Kernighan and Ritchie,(First Edition).


Next topic: Global behavior
Previous topic: Compilation modes

© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005