16. Preprocessor¶
This chapter briefly describes the preprocessor and covers commonly used macros.
16.1. Overview¶
The preprocessor adheres to Standard C, providing:
Predefined macros for inspecting the compilation environment, allowing application tuning based on compiler properties.
User-defined macros, specified via the command line or within C source files.
The ability to dump the preprocessor environment for inspection.
The ability to dump the source file after preprocessing.
Predefined macros¶
The following describes the macros which are the ones you are most likely to use in conditional builds.
__STDC__¶
This macro is set to 1, indicating that this compiler adheres to Standard C.
__STDC_HOSTED__¶
This macro is defined as 0, indicating a cross-compiler. You can test this as follows:
#if defined(__STDC_HOSTED__) && __STDC_HOSTED__ == 0
__STDC_VERSION__¶
This macro is set to 199901L to indicate that this compiler
adheres to the ISO/IEC 9899:1999 standard.
__CALYPSI__¶
This macro is set to 1, indicating that either the assembler or compiler in use is from Calypsi.
__CALYPSI_CC__¶
This is set to 1, indicating that this is a Calypsi C compiler.
__CALYPSI_ASSEMBLER__¶
This macro is set to 1 when a Calypsi assembler is used.
__CALYPSI_DEBUG__¶
This macro is defined and set to 1 when compiling with debug
information enabled, i.e. --debug or -g command-line option
used.
__CALYPSI_VERSION_MAJOR__¶
This macro is set to the first number of the version.
__CALYPSI_VERSION_MINOR__¶
This macro is set to the second number of the version.
__BIG_ENDIAN__¶
This macro is defined if the target has big-endian byte order.
__LITTLE_ENDIAN__¶
This macro is defined if the target has little-endian byte order.
__BYTE_ORDER__¶
This macro defines the byte order, taking the value of __ORDER_LITTLE_ENDIAN__,
__ORDER_BIG_ENDIAN__, or __ORDER_PDP_ENDIAN__.
It is usually simpler to use __BIG_ENDIAN__ or __LITTLE_ENDIAN__
macros for conditional inclusion of endian-dependent source code.
__ORDER_LITTLE_ENDIAN__¶
This macro is defined to 1234 to describe the byte order in memory for a little-endian target.
__ORDER_BIG_ENDIAN__¶
This macro is defined as 4321, describing the byte order in memory for a big-endian target.
__ORDER_PDP_ENDIAN__¶
This macro is defined as 3412, describing the byte order in memory for a PDP-endian target.
__FILE__¶
This macro expands to the name of the current source file.
__LINE__¶
This macro expands to the current line number in the source file.
__DATE__¶
This macro expands to the current date.
__TIME__¶
This macro expands to the current time of the day.
__COUNTER__¶
This macro expands to a number that increments every time the macro is used.
__CALYPSI_TARGET_65816__¶
Set to 1 when the target is the 65816 family.
__CALYPSI_CORE_65816__¶
Set to 1 when the 65816 core is selected.
You can test for this core using #ifdef __CALYPSI_CORE_65816__.
__CALYPSI_TARGET_SYSTEM_EMBEDDED__¶
Set to 1 when the compiler is configured for an embedded system,
generating code suitable for flash or ROM memory.
You can test if the compiler is configured for an embedded system using #ifdef
__CALYPSI_TARGET_SYSTEM_EMBEDDED__.
__CALYPSI_TARGET_SYSTEM_C256__¶
Set to 1 when the compiler is configured for the Foenix C256.
__CALYPSI_TARGET_SYSTEM_F256__¶
Set to 1 when the compiler is configured for the Foenix F256.
__CALYPSI_TARGET_SYSTEM_SNES__¶
Set to 1 when the compiler is configured for the Super Nintendo Entertainment System.
__CALYPSI_CODE_MODEL_SMALL__¶
Set to 1 if the compiler uses the Small code model.
__CALYPSI_CODE_MODEL_COMPACT__¶
Set to 1 if the compiler uses the Compact code model.
__CALYPSI_CODE_MODEL_LARGE__¶
Set to 1 if the compiler uses the Large code model.
__CALYPSI_DATA_MODEL_SMALL__¶
Set to 1 if the compiler uses the Small data model.
__CALYPSI_DATA_MODEL_MEDIUM__¶
Set to 1 if the compiler uses the Medium data model.
__CALYPSI_DATA_MODEL_LARGE__¶
Set to 1 if the compiler uses the Large data model.
__CALYPSI_DATA_MODEL_HUGE__¶
Set to 1 if the compiler uses the Huge data model.
__CALYPSI_HUGE_ATTRIBUTE_ENABLED__¶
Set to 1 if the Huge attribute is enabled via
--enable-huge-attribute, which also makes size_t 32 bits.