Run the C preprocessor before the ESQL/C preprocessor
The compilation of the source file can follow either the default order, where the preprocessor runs first on the source file, or it can allow the C preprocessor to run on the source file before the preprocessor.
- The preprocessor
performs the following steps to create a .c file
from the source
file:
- Incorporates header files into the source file when it processes all include directives ($include and EXEC SQL include statements)
- Creates or removes compile-time definitions when it processes all define ($define and EXEC SQL define) and undef ($undef and EXEC SQL undef) directives
- Processes any conditional compilation directives (ifdef, ifndef, else, elif, endif) and translates embedded SQL statements to function calls and special data structures
- The C preprocessor takes the following actions:
- Incorporates C header files into the source file when it processes all C include directives (#include)
- Creates or removes compile-time definitions when it processes all C language define (#define) and undef (#undef) directives
- Processes C conditional compilation directives (#ifdef, #ifndef, #else, #elif, #endif)
- The C compiler, assembler, and linker work in the usual way, as they do for a C source file, translating the C code file into an executable program.
This default order of compilation is restrictive because you cannot use #defines or typedefs defined in C system header files or custom C header files to define host variables and constants, nor can you use them for conditional compilation of code. With the default order of compilation, C header files do not get included into the source code until after the preprocessor has run, making these definitions unavailable to the preprocessor.