You can define a feature-test macro to select each standard. You can do this either with a #define preprocessor directive in your C source before the inclusion of any header file, or with the /DEFINE qualifier on the CC command line. Features not defined by one of the previously named standards are considered VSI C extensions and are selected by not defining any standards-related, feature-test macros. If you do not explicitly define feature test macros to control header file definitions, you implicitly include all defined symbols as well as VSI C extensions.
1 – XOPEN SOURCE EXTENDED
Makes visible XPG4-extended features, including traditional UNIX based interfaces not previously adopted by X/Open. Standard Selected: XPG4 V2 Other Standards Implied: XPG4, ISO POSIX-2, ISO POSIX-1, ANSI C
2 – XOPEN SOURCE
Makes visible XPG4 standard symbols and causes _POSIX_C_SOURCE to be set to 2 if it is not already defined with a value greater than 2. Notes: o Where the ISO C Amendment 1 includes symbols not specified by XPG4, defining __STDC_VERSION__ == 199409 and _XOPEN_SOURCE (or _XOPEN_SOURCE_EXTENDED) selects both ISO C and XPG4 APIs. Conflicts that arise when compiling with both XPG4 and ISO C Amendment 1 resolve in favor of ISO C Amendment 1. o Where XPG4 extends the ISO C Amendment 1, defining _XOPEN_ SOURCE or _XOPEN_SOURCE_EXTENDED selects ISO C APIs as well as the XPG4 extensions available in the header file. This mode of compilation makes XPG4 extensions visible. Standard Selected: XPG4 Other Standards Implied: XPG4, ISO POSIX-2, ISO POSIX-1, ANSI C
3 – POSIX C SOURCE==199506
Header files defined by ANSI C make visible those symbols required by IEEE 1003.1c-1995. Standard Selected: IEEE 1003.1c-1995 Other Standards Implied: ISO POSIX-2, ISO POSIX-1, ANSI C
4 – POSIX C SOURCE==2
Header files defined by ANSI C make visible those symbols required by ISO POSIX-2 plus those required by ISO POSIX-1. Standard Selected: ISO POSIX-2 Other Standards Implied: ISO POSIX-1, ANSI C
5 – POSIX C SOURCE==1
Header files defined by ANSI C make visible those symbols required by ISO POSIX-1. Standard Selected: ISO POSIX-1 Other Standards Implied: ANSI C
6 – STDC VERSION ==199409
Makes ISO C Amendment 1 symbols visible. Standard Selected: ISO C Amendment 1 Other Standards Implied: ANSI C
7 – ANSI C SOURCE
Makes ANSI C standard symbols visible. Standard Selected: ANSI C Other Standards Implied: None.
8 – Interactions with the /STANDARD Qualifier
The /STANDARD qualifier selects the dialect of the C language supported. With the exception of /STANDARD=ANSI89 and /STANDARD=ISOC94, the selection of C dialect and the selection of C RTL APIs to use are independent choices. All other values for /STANDARD cause the entire set of APIs to be available, including extensions. Specifying /STANDARD=ANSI89 restricts the default API set to the ANSI C set. In this case, to select a broader set of APIs, you must also specify the appropriate feature-test macro. To select the ANSI C dialect and all APIs, including extensions, undefine __HIDE_FORBIDDEN_NAMES before including any header file. Compiling with /STANDARD=ISOC94 sets __STDC_VERSION__ to 199409. Conflicts that arise when compiling with both XPG4 and ISO C Amendment 1 resolve in favor of ISO C Amendment 1. XPG4 extensions to ISO C Amendment 1 are selected by defining _XOPEN_ SOURCE. The following examples help clarify these rules: o The fdopen function is an ISO POSIX-1 extension to <stdio.h>. Therefore, <stdio.h> defines fdopen only if one or more of the following is true: - The program including it is not compiled in strict ANSI C mode (/STANDARD=ANSI89). - _POSIX_C_SOURCE is defined as 1 or greater. - _XOPEN_SOURCE is defined. - _XOPEN_SOURCE_EXTENDED is defined. o The popen function is an ISO POSIX-2 extension to <stdio.h>. Therefore, <stdio.h> defines popen only if one or more of the following is true: - The program including it is not compiled in strict ANSI C mode (/STANDARD=ANSI89). - _POSIX_C_SOURCE is defined as 2 or greater. - _XOPEN_SOURCE is defined. - _XOPEN_SOURCE_EXTENDED is defined. o The getw function is an X/Open extension to <stdio.h>. Therefore, <stdio.h> defines getw only if one or more of the following is true: - The program is not compiled in strict ANSI C mode (/STANDARD=ANSI89). - _XOPEN_SOURCE is defined. - _XOPEN_SOURCE_EXTENDED is defined. o The X/Open Extended symbolic constants _SC_PAGESIZE, _SC_PAGE_SIZE, _SC_ATEXIT_MAX, and _SC_IOV_MAX were added to <unistd.h> to support the sysconf function. However, these constants are not defined by _POSIX_C_SOURCE. The <unistd.h> header file defines these constants only if a program does not define _POSIX_C_SOURCE and does define _XOPEN_SOURCE_EXTENDED. If _POSIX_C_SOURCE is defined, these constants are not visible in <unistd.h>. Note that _POSIX_C_SOURCE is defined only for programs compiled in strict ANSI C mode. o The fgetname function is a C RTL extension to <stdio.h>. Therefore, <stdio.h> defines fgetname only if the program is not compiled in strict ANSI C mode (/STANDARD=ANSI89). o The macro _PTHREAD_KEYS_MAX is defined by POSIX 1003.1c-1995. This macro is made visible in <limits.h> when compiling for this standard with _POSIX_C_SOURCE == 199506 defined, or by default when compiling without any standards-defining, feature-test macros. o The macro WCHAR_MAX defined in <wchar.h> is required by ISO C Amendment 1 but not by XPG4. Therefore: - Compiling for ISO C Amendment 1 makes this symbol visible, but compiling for XPG4 compliance does not. - Compiling for both ISO C Amendment 1 and XPG4 makes this symbol visible. Similarly, the functions wcsftime and wcstok in <wchar.h> are defined slightly differently by the ISO C Amendment 1 and XPG4: - Compiling for ISO C Amendment 1 makes the ISO C Amendment 1 prototypes visible. - Compiling for XPG4 compliance makes the XPG4 prototypes visible. - Compiling for both ISO C Amendment 1 and XPG4 selects the ISO C prototypes because conflicts resulting from this mode of compilation resolve in favor of ISO C. - Compiling without any standard selecting feature test macros makes ISO C Amendment 1 features visible. In this example, compiling with no standard-selecting feature-test macros makes WCHAR_MAX and the ISO C Amendment 1 prototypes for wcsftime and wcstok visible. o The wcswidth and wcwidth functions are XPG4 extensions to ISO C Amendment 1. Their prototypes are in <wchar.h>. These symbols are visible if: - Compiling for XPG4 compliance by defining _XOPEN_SOURCE or _XOPEN_SOURCE_EXTENDED. - Compiling for DEC C Version 4.0 compatibility or on pre- OpenVMS Version 7.0 systems. - Compiling with no standard-selecting feature-test macros. - Compiling for both ISO C Amendment 1 and XPG4 compilance because these symbols are XPG4 extensions to ISO C Amendment 1. Compiling for strict ISO C Amendment 1 does not make them visible.