SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
C/C++ Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
15-13
Preprocessor Output
Executable SQL Statements
The preprocessor performs these functions:
•
Scans the statement for host variables (indicated by a colon) and ensures that 
each host variable is declared within the current scope of the program.
•
Converts the SQL statement to a C comment in the C/C++ annotated source file.
•
Writes the appropriate CLI procedure call or calls for the SQL statement 
immediately after the commented statement in the C/C++ annotated source file. At 
run time, the calls invoke the SQL/MX executor to execute the procedure for the 
SQL statement within the module.
•
Writes the executable SQL statement to a separate module definition file if you use 
the -x or -m preprocessor option or set the 
SQLMX_PREPROCESSOR_VERSION=800 environment variable.
Use the preprocessor to embed SQL anywhere in the C/C++ source file. However, the 
preprocessor determines in which part of the source file the embedded SQL is located 
and issues warnings if an embedded SQL statement is not placed correctly. See 
Placement of SQL Statements on page 2-2.
At the end of processing the embedded SQL C/C++ source file, the preprocessor 
checks the status of static cursors:
•
Cursors accessed and not opened return an error message.
•
Cursors declared and not accessed return a warning message.
Preprocessor Output
C/C++ Annotated Source File for Embedded Module 
Definitions
The SQL/MX C/C++ preprocessor processes a C/C++ source file, such as source-
file.sql, and generates one annotated source file (source-file.c in C or 
source-file.cpp in C++) as its output file. The annotated source file contains the 
embedded module definitions.
C/C++ Annotated Source File for Module Definition Files
If you use the -x or -m preprocessor option or if you set the 
SQLMX_PREPROCESSOR_VERSION=800 environment variable, the preprocessor 
processes a C/C++ source file, such as source-file.sql, and generates two files: 
the annotated source file (source-file.c in C or source-file.cpp in C++) and the 
module definition file (source-file.m). 
For more information on module management behavior and influencing the 
preprocessor, see Module Management Behavior on page 17-7. For recommended 
naming conventions for C/C++ source files, see Table 17-1 on page 17-1.










