Default compilation order

After you have created the Informix® ESQL/C program file, you run the esql command on that file. By default, the Informix ESQL/C preprocessor runs first and translates the embedded SQL statements in the program into Informix ESQL/C function calls that communicate with the database server. The Informix ESQL/C preprocessor produces a C source file and calls the C compiler. The C compiler then preprocesses and compiles your source file and links any other C source file, object file, or library file the same way as any other C program. If esql does not encounter errors in one of these steps, it generates an executable file. You can run the compiled Informix ESQL/C program as you would any C program. When the program runs, it calls the Informix ESQL/C library procedures; the library procedures set up communications with the database server to carry out the SQL operations.

The following figure illustrates the process by which the Informix ESQL/C program becomes an executable program.
Figure 1: Relationship between Informix ESQL/C and C


Important: Keep in mind that with the default order of compilation, esql handles Informix ESQL/C preprocessor directives before it calls the C compiler. Therefore, the Informix ESQL/C directives take effect before the C compiler performs any preprocessing. You cannot access Informix ESQL/C definitions within C preprocessor directives, nor can you use the C preprocessor to perform conditional compilation of Informix ESQL/C statements.