Using the DB2 C/C++ precompiler

The DB2® C/C++ precompiler scans source code for potentially SQL-related keywords, such as the following:
  • Host variables that can be used in SQL statements in the same source.
  • SQL statements that start with the token pair EXEC SQL.
While the DB2 C/C++ precompiler can fully parse the SQL syntax, it has limited capacity for parsing compiler-language-related syntax. If you are compiling code with SQL in effect, all DB2 z/OS® XL C/C++ code should be written in codepage IBM®-1047 (APL293).

An advantage of using the DB2 C/C++ precompiler instead of the XL C/C++ DB2 coprocessor is that you can obtain a more useful message listing by preprocessing, precompiling, and then compiling source code with embedded SQL statements. Compiler diagnostics refer to line numbers of the translated output from the DB2 C/C++ precompiler, not to the line numbers of your source code. This means that you need both the DB2 C/C++ precompiler listing and the compiler listing to work through the compilation errors. Runtime troubleshooting tools also refer to coordinates of the DB2 C/C++ precompiler output.