SQL/MX 3.2 Programming Manual for C and COBOL (H06.25+, J06.14+)

C/C++ Program Compilation
HP NonStop SQL/MX Release 3.2 Programming Manual for C and COBOL663854-002
15-9
Preprocessor Functions
Windows workstation. For information, see the SQL/MX Release 3.2 Installation and
Upgrade Guide.
The syntax for using the preprocessor in each environment appears under Syntax for
the OSS-Hosted SQL/MX C/C++ Preprocessor on page 15-20 and Syntax for the
Windows-Hosted SQL/MX C/C++ Preprocessor on page 15-28.
Preprocessor Functions
The preprocessor processes C/C++ and SQL source statements.
C/C++ Source Statements
The preprocessor writes each C/C++ source statement to the C/C++ annotated source
file. The preprocessor parses the source file only to the extent necessary to detect
scoping levels, host variable declarations, host variable expressions, and embedded
SQL statements.
C Preprocessing Directives
The preprocessor ignores the C directives except the #include, #define, #line,
#pragma, or conditional compilation directives.
The pragma #pragma SQL CHAR_AS_ARRAY – SQL/MX Release 3.1, supports the
CHAR_AS_ARRAY pragma in the embedded SQL file. The length of all character
descriptors will be the same as the descriptors defined in the application, unlike the
default length, where the length is one byte less than that defined.
The pragma can be placed anywhere in the file. However, the pragma will be effective
from one definition until the next or until the end of file.
The following example uses the pragma SQL CHAR_AS_ARRAY:
#pragma SQL CHAR_AS_ARRAY
EXEC SQL BEGIN DECLARE SECTION;
char a[20];
EXEC SQL END DECLARE SECTION;
---
strcpy(a,"abc");
EXEC SQL INSERT INTO t1 (val) values(:a);