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 COBOL523627-004
15-11
Preprocessor Functions
C #define Directive
The preprocessor scans all #define directives and stores them in a table for
evaluation when they are encountered. The preprocessor evaluates the stored defines
for all legal combinations of conditional compilation.
A #define specified on the preprocessor command line must also be specified on the
C/C++ command line. The preprocessor interprets and uses #define information but
does not remove it from the generated code. The C/C++ compiler must get the same
directive to interpret the code the same way. If you use the c89 utility, this is not a
concern.
The preprocessor checks each nonkeyword that begins a line to determine if it is in the
define table. If it is, it is expanded. However, you must ensure that define-engendered
substitutions result in valid code.
This #define directive:
#define SQL_Control_Table(defname)
EXEC SQL CONTROL TABLE defname TABLELOCK ‘OFF’;
SQL_Control_Table(fldrenty);
SQL_Control_Table(postact);
SQL_Control_Table(permdeny);
is expanded to:
EXEC SQL CONTROL TABLE fldrenty TABLELOCK 'OFF';
EXEC SQL CONTROL TABLE postact TABLELOCK 'OFF';
EXEC SQL CONTROL TABLE permdeny TABLELOCK 'OFF';
The preprocessor also expands #define directives that occur within host variable
parameters.
This #define directive:
#define MAX 255
EXEC SQL BEGIN DECLARE SECTION;
char mystr [MAX-1];
EXEC SQL END DECLARE SECTION;
is expanded to:
#define MAX 255
EXEC SQL BEGIN DECLARE SECTION;
char mystr [/*MAX-1*/ 254];
EXEC SQL END DECLARE SECTION;
C #line Directive
The preprocessor generates #line directives in the C/C++ annotated source file so
that the user, during debugging, is directed to the input source line number and file
name instead of the preprocessor-generated code that implements the embedded SQL