![]() |
CITS2002 Systems Programming |
← prev | next → | ![]() |
![]() |
|||
Pre-defined preprocessor tokensThe recent examples enabling detection of C language standard and operating system platform, are a small, but important sample of the information available when compiling programs. We can see the pre-processor's pre-defined tokens with:
prompt> cc -dM -E - < /dev/null Some of the following examples (not specifically related to portability) taken from: gcc's Standard Predefined Macros The standard predefined macros are specified by the relevant language standards, so they are available with all compilers that implement those standards.
__STDC__ In normal operation, this macro expands to the constant 1, to signify that this compiler conforms to ISO Standard C. __STDC_VERSION__ This macro expands to the C Standard’s version number, a long integer
constant of the form __STDC_HOSTED__ This macro is defined, with value 1, if the compiler’s target is a hosted environment. A hosted environment has the complete facilities of the standard C library available.
CITS2002 Systems Programming, Lecture 22, p4, 16th October 2023.
|