Variable Declarations Syntax
The syntax of a variable declaration is:
[storage_class] type_specification
declarator {, declarator};
where each declarator is:
variable_name [= initial_value]
Syntax Notes:
• Storage_class is optional, but if specified can be any of the following:
auto
extern
register
static
varchar
VMS also uses globaldef and globalref unless you are using ANSI C on VMS.
The storage class provides no data type information to the preprocessor. For more detail on the EQUEL-defined
varchar storage class, see
The Varying Length String Type.
• Although register variables are supported, be careful when using them in EQUEL statements. In database statements, such as the append and retrieve statements, the preprocessor generates C function calls which may pass a variable by reference using the ampersand operator (&). However, some compilers do not allow you to use register variables in this manner.
• Because of the syntactic similarity between the EQUEL register statement and the C register declaration, the preprocessor does not allow you to represent the initial object name in the EQUEL register statement with a host variable.
• The
type_specification must be an EQUEL type, a type built up with a
typedef declaration (and known to the preprocessor), or a structure or union specification.
For a discussion of
Typedef declarations, see
Type Declarations Syntax. For a discussion of structures, see
Structure Declarations Syntax.
• Precede the
variable_name by an asterisk (*), to denote a pointer variable, or follow it by a bracketed expression (
[expr]), to denote an array variable. For a discussion of pointers, see
Pointer Declarations Syntax. For a discussion of arrays, see
Array Declarations Syntax.
• Begin the variable_name with a legal C identifier name that starts with an underscore or alphabetic character.
• The preprocessor does not evaluate the initial_value. Consequently, the preprocessor accepts any initial value, even if it can later cause a C compiler error. For example, the preprocessor accepts both of the following initializations, even though only the first is a legal C statement:
## char *msg = "Try again";
## int rowcount = {0, 123};
The following example illustrates some valid EQUEL/C declarations:
## extern int first_employee;
## auto long update_mode = 1;
## static char *names[3] = {"neil", "mark", "barbara"};
## static char *names[3] = {"john", "bob", "tom"};
## char **nameptr = names;
## short name_counter;
## float last_salary = 0.0, cur_salary = 0.0;
## double stat_matrix[STAT_ROWS][STAT_COLS];