The define and undef directives

The Informix® ESQL/C preprocessor allows you to create simple variables that are available only to the Informix® ESQL/C preprocessor. Informix® calls these variables definitions. The Informix® ESQL/C preprocessor manages these definitions with two directives:
define
Creates a name-flag definition. The scope of this definition is from the point where you define it to the end of the Informix® ESQL/C source file.
undef
Removes a name flag that EXEC SQL define or $define creates.

The Informix® ESQL/C preprocessor rather than the C preprocessor (which processes #define and #undef) processes these directives. The Informix® ESQL/C preprocessor creates (define) or removes (undef) these definitions in stage 1 of preprocessing.

The Informix® ESQL/C define directive can create definitions with the following formats:
  • The format for Boolean symbols is define symbolname;
    The following examples show the two ways to define a Boolean symbol that is called TRANS:
    EXEC SQL define TRANS;
    $define TRANS;
  • The format for integer constants is define symbolname value;
    The following examples show both formats for two integer constants, MAXROWS (with a value of 25), and USETRANSACTIONS (with a value of 1):
    EXEC SQL define MAXROWS 25;
    $define MAXROWS 25;
    
    EXEC SQL define USETRANSACTIONS 1;
    $define USETRANSACTIONS 1;
Important: Unlike the C #define statement, the define directive does not support string constants or macros of statements that receive values at run time.

You can override define and undef statements in the source program with the esql command-line options, -ED and -EU. For more information about these options, see Define and undefine definitions while preprocessing.