C-preprocessor directives v17
The ECPGPlus C-preprocessor enforces two behaviors that depend on the mode in which you invoke ECPGPlus:
PROC
mode- Non-
PROC
mode
Compiling in PROC mode
In PROC
mode, ECPGPlus allows you to:
- Declare host variables outside of an
EXEC SQL BEGIN/END DECLARE SECTION
. - Use any C variable as a host variable as long as its data type is compatible with ECPG.
When you invoke ECPGPlus in PROC
mode (by including the -C PROC
keywords), the ECPG compiler honors the following C-preprocessor directives:
Preprocessor directives are used to affect or direct the code that's received by the compiler. For example, consider the following code sample:
Suppose you invoke ECPGPlus with the following command-line arguments:
ECPGPlus copies the entire fragment, without change, to the output file. It sends only the following tokens to the ECPG parser:
On the other hand, suppose you invoke ECPGPlus with the following command-line arguments:
The ECPG parser receives the following tokens:
If your code uses preprocessor directives to filter the code that's sent to the compiler, the complete code is retained in the original code, while the ECPG parser sees only the processed token stream.
You can also use compatible syntax when executing the following preprocessor directives with an EXEC
directive:
For example, suppose your code includes the following: