Section 14.8. Predefined Macros


14.8. Predefined Macros

Every compiler that conforms to the ISO C standard must define the following seven macros. Each of these macro names begins and ends with two underscore characters:


_ _DATE_ _

The replacement text is a string literal containing the compilation date in the format "Mmm dd yyyy" (example: "Mar 19 2006"). If the day of the month is less than 10, the tens place contains an additional space character.


_ _FILE_ _

A string literal containing the name of the current source file.


_ _LINE_ _

An integer constant whose value is the number of the line in the current source file that contains the _ _LINE_ _ macro reference, counting from the beginning of the file.


_ _TIME_ _

A string literal that contains the time of compilation, in the format "hh:mm:ss" (example: "08:00:59").


_ _STDC_ _

The integer constant 1, indicating that the compiler conforms to the ISO C standard.


_ _STDC_HOSTED_ _

The integer constant 1 if the current implementation is a hosted implementation; otherwise the constant 0.


_ _STDC_VERSION_ _

The long integer constant 199901L if the compiler supports the C99 standard of January 1999.

The values of the _ _FILE_ _ and _ _LINE_ _ macros can be influenced by the #line directive. The values of all the other predefined macros remains constant throughout the compilation process.

The value of the constant _ _STDC_VERSION_ _ will be adjusted with each future revision of the international C standard.

Under the C99 standard, C programs are executed either in a hosted or in a freestanding environment. Most C programs are executed in a hosted environment, which means that the C program runs under the control and with the support of an operating system. In this case, the constant _ _STDC_HOSTED_ _ has the value 1, and the full standard library is available.

A program in a freestanding environment runs without the support of an operating system, and therefore only minimal standard library resources are available to it (see "Execution Environments" in Chapter 15).

Unlike the macros listed previously, the following standard macros are optional. If any of these macros is defined, it indicates that the implementation supports a certain IEC or ISO standard:


_ _STDC_IEC_559_ _

This constant is defined with the value 1 if the implementation's real floating-point arithmetic conforms to the IEC 60559 standard.


_ _STDC_IEC_559_COMPLEX_ _

This constant is defined with the value 1 if the implementation's complex floating-point arithmetic also conforms to the IEC 60559 standard.


_ _STDC_ISO_10646_ _

This long integer constant represents a date in the form yyyymmL (example: 199712L). This constant is defined if the encoding of wide characters with type wchar_t conforms to the ISO/IEC 10646 standard, including all supplements and corrections up to the year and month indicated by the macro's value.

You must not use any of the predefined macro names described in this section in a #define or #undef directive. Finally, the macro name _ _cplusplus is reserved for C++ compilers, and must not be defined when you compile a C source file.



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net