Run the C preprocessor before the ESQL/C preprocessor

The compilation of the Informix® ESQL/C source file can follow either the default order, where the Informix® ESQL/C preprocessor runs first on the source file, or it can allow the C preprocessor to run on the source file before the Informix® ESQL/C preprocessor.

The default sequence of compilation for the Informix® ESQL/C source file is as follows:
  1. The Informix® ESQL/C preprocessor performs the following steps to create a .c file from the Informix® ESQL/C source file:
    • Incorporates Informix® ESQL/C 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 Informix® ESQL/C function calls and special data structures
  2. 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)
  3. 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 Informix® ESQL/C host variables and constants, nor can you use them for conditional compilation of Informix® ESQL/C code. With the default order of compilation, C header files do not get included into the Informix® ESQL/C source code until after the Informix® ESQL/C preprocessor has run, making these definitions unavailable to the Informix® ESQL/C preprocessor.