Declare variables with non-ANSI storage-class modifiers
The ANSI C standards define a set of storage-class specifiers for variable declarations. The C compilers in Windows™ environments often support non-ANSI storage-class specifiers. To provide support for these non-ANSI storage-class specifiers in host-variable declarations, the preprocessor supports the form of the ANSI syntax, as shown.
Element | Purpose | Restrictions | Syntax |
---|---|---|---|
modifier name | Text that you want to pass to the C compiler for
translation. This text is usually the name of the storage-class modifier. |
The modifier must be valid for your C compiler or be a name that you define in your program. | See your C compiler documentation. |
variable name | Identifier name of the ESQL/C host variable | None. | See Declare a host variable. |
variable type | Data type of the ESQL/C host variable | The type must be a valid C or ESQL/C data type. | See Declare a host variable. |
__declspec(attribute) var_type var_name;
In this example, attribute is a supported keyword (such as thread, dllimport, or dllexport), var_type is the data type of the variable, and var_name is the variable name.
@("__declspec(attribute)") var_type var_name;
#define DLLTHREAD __declspec(thread)
;
EXEC SQL BEGIN DECLARE SECTION;
@("DLLTHREAD") int threadCount;
EXEC SQL END DECLARE SECTION;
#define DLLEXPORT __declspec(dllexport);
;
EXEC SQL BEGIN DECLARE SECTION;
@("DLLEXPORT") int winHdl;
EXEC SQL END DECLARE SECTION;