INFORMIX
Informix-ESQL/C Programmer's Manual
Chapter 1: Programming with INFORMIX-ESQL/C
Home Contents Index Master Index New Book
WIN NT/95

Using Host Variables in Windows Environments

This section describes the following topics about ESQL/C host variables that are unique to the Windows environments:

Declaring Variables with Non-ANSI Storage-Class Modifiers

The ANSI C standards define a set of storage-class specifiers for variable declarations. C compilers in Windows environments often support non-ANSI storage-class specifiers. To provide support for these non-ANSI storage-class specifiers in ESQL/C host-variable declarations, the ESQL/C preprocessor supports the form of the ANSI syntax that Figure 1-31 shows.

Figure 1-31

ESQL/C Syntax for Non-ANSI Storage-Class Specifiers
Element Purpose Restrictions Syntax

modifier name

The 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

The identifier name of the ESQL/C host variable

None.

See "Declaring a Host Variable".

variable type

The data type of the ESQL/C host variable

The type must be a valid C or ESQL/C data type.

See "Declaring a Host Variable".

For example, the Microsoft Visual C++ compiler supports the declspec compiler directive to enable you to declare extended storage-class attributes. This compiler directive has the following syntax:

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.

To enable you to declare ESQL/C host variables as extended storage-class variables, the ESQL/C preprocessor supports the declspec directive with the following syntax:

In this example, attribute, var_type, and var_name are the same as in the previous example. You might find it convenient to declare a macro for the declspec syntax. The following example declares threadCount as an instance-specific integer variable of the thread-extended storage class:

This example creates the DLLTHREAD macro to simplify the declaration of thread-extended storage-class attributes. You could declare similar macros to simplify declaration of variables to be exported (or imported) to the dynamic link library (DLL), as follows:

Using Global ESQL/C Variables

In earlier versions of the ESQL/C product, ESQL/C provided several global variables to support different features. Figure 1-32 describes these global variables.

Figure 1-32
Global ESQL/C Variables

Global Variable Description

SQLSTATE

An ANSI-compliant status code as a five-character string (plus null terminator)

For more information about SQLSTATE, see Chapter 11, "Exception Handling."

SQLCODE
sqlca.sqlcode

An Informix-specific status code as an integer value

For more information about SQLCODE, see Chapter 11, "Exception Handling."

sqlca structure

Informix-specific diagnostic information

For more information about this structure, see Chapter 11, "Exception Handling."

FetBufSize

The size of the fetch buffer

For more information on FetBufSize, see Chapter 14, "Using Dynamic SQL."

InetLogin
structure

Environment information for the client ESQL/C application.

For more information, see "InetLogin Structure".

In Windows environments, ESQL/C implements the global variables in Figure 1-32 as functions, which the sqlhdr.h file defines. These functions return values that have the same data types as their global-variable counterparts. Therefore, this change in implementation does not require modification of existing ESQL/C code. You can still use these functions in the same context as their global-variable counterparts.




Informix-ESQL/C Programmer's Manual, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.