16. Preprocessor

This chapter briefly describes the preprocessor and covers commonly used macros.

16.1. Overview

The preprocessor adheres to Standard C, providing:

  1. Predefined macros for inspecting the compilation environment, allowing application tuning based on compiler properties.

  2. User-defined macros, specified via the command line or within C source files.

  3. The ability to dump the preprocessor environment for inspection.

  4. 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_68000__

Set to 1 when the target is the 68000 family.

__CALYPSI_CORE_68000__

Set to 1 if the selected core is 68000. You can test if the core is 68000 using #ifdef __CALYPSI_CORE_68000__.

__CALYPSI_CORE_68010__

Set to 1 if the selected core is 68010. You can test if the core is 68010 using #ifdef __CALYPSI_CORE_68010__.

__CALYPSI_CORE_68020__

Set to 1 if the selected core is 68020. You can test if the core is 68020 using #ifdef __CALYPSI_CORE_68020__.

__CALYPSI_CORE_68030__

Set to 1 if the selected core is 68030. You can test if the core is 68030 using #ifdef __CALYPSI_CORE_68030__.

__CALYPSI_CORE_68040__

Set to 1 if the selected core is 68040. You can test if the core is 68040 using #ifdef __CALYPSI_CORE_68040__.

__CALYPSI_CORE_68060__

Set to 1 if the selected core is 68060. You can test if the core is 68060 using #ifdef __CALYPSI_CORE_68060__.

__CALYPSI_CORE_68080__

Set to 1 if the selected core is 68080. You can test if the core is 68080 using #ifdef __CALYPSI_CORE_68080__.

__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_AMIGA__

Set to 1 if the compiler is configured for the Amiga target. You can test if the compiler is configured for the Amiga target using #ifdef __CALYPSI_TARGET_SYSTEM_AMIGA__.

__CALYPSI_TARGET_SYSTEM_A2560K__

Set to 1 if the compiler is configured for the Foenix A2560K. You can test if the compiler is configured for the Foenix A2560K using #ifdef __CALYPSI_TARGET_SYSTEM_A2560K__.

__CALYPSI_TARGET_SYSTEM_A2560U__

Set to 1 if the compiler is configured for the Foenix A2560U. You can test if the compiler is configured for the Foenix A2560U using #ifdef __CALYPSI_TARGET_SYSTEM_A2560U__.

__CALYPSI_TARGET_SYSTEM_TOS__

Set to 1 if the compiler is configured for the TOS target. You can test if the compiler is configured for the Amiga target using #ifdef __CALYPSI_TARGET_SYSTEM_TOS__.

__CALYPSI_CODE_MODEL_SMALL__

This macro is set to 1 if the compiler is configured to use the Small code model.

__CALYPSI_CODE_MODEL_LARGE__

This macro is set to 1 if the compiler is configured to use the Large code model.

__CALYPSI_DATA_MODEL_SMALL__

This macro is set to 1 if the compiler is configured to use the Small data model.

__CALYPSI_DATA_MODEL_LARGE__

This macro is set to 1 if the compiler is configured to use the Large data model.

__CALYPSI_DATA_MODEL_FAR_ONLY__

This macro is set to 1 if the compiler is configured to use the Far-only data model.