{ [declaration ...] [statement ...] }
The declaration list is optional; if it is included, all declarations of variables are local to the block and supersede previous declarations for the duration of the block. Any auto or register variables are initialized each time the block is entered normally; the initializations do not occur if the block is entered by a goto statement. Blocks can be used wherever single statements are valid--for example, as the action clause of an if statement:
if ( i < 1 ) { /* BEGINNING OF BLOCK */ char x; for (x = 'a'; x <= 'z'; x++) printf("char = %c\n", x); } /* END OF BLOCK */
Valid_File_Specifications
Since the VAX C Run-time Library (RTL) includes functions from the
DEC/Shell RTL, all valid VMS file specifications and most UNIX*
system file specifications are acceptable. Combinations of the two
specifications are not supported by VAX C.
An example of a valid UNIX file specification is as follows:
beatle!/dba0/lennon/songs.lis.3
An example of an invalid file specification is as follows:
BEATLE::DBA0:[LENNON.C]/songs.lis.3
---------- * UNIX is a registered trademark of American Telephone and Telegraph Company.
Data_Types
The data type of an object must be specified in its declaration.
The fundamental data types are the scalar types:
int 32-bit signed integer unsigned 32-bit unsigned integer float single-precision floating-point number double double-precision floating-point number enum enumerated type char character
The adjectives short and long can be used to specify the size of the object. For example, a short int is a 16-bit signed integer. A long int is the same as an int in VAX C. A long float is the same as a double.
The unsigned keyword can also be used as an adjective. An unsigned short or unsigned char is a 16- or 8-bit unsigned integer, respectively.
Additional Information on:
declaration ::= decl-specifier ... [init-declarator,...] ; decl-specifier ::= type-specifier [decl-specifier,...] sc-specifier [decl-specifier,...] dm-specifier [decl-specifier,...]
"decl-specifiers" give the data types and, optionally, storage classes of the declared objects. "init-declarators" list the declared identifiers and, optionally, their initial values.
For more information, see HELP CC lANGUAGE_TOPICS DATA_TYPES, HELP CC LANGUAGE_TOPICS STORAGE_CLASSES, and HELP CC LANGUAGE_TOPICS DATA_TYPE_MODIFIERS.
Additional Information on:
Function declarations have the following syntax:
function_name() or function_name(arg1,arg2,...) or function_name(data-type arg1, data-type arg2,...)
In the first form of the function declaration, the function takes no arguments. In the second form, the function takes arguments. In the third form, the function declaration is a function prototype that specifies the data type of its arguments in the identifier list. In all three cases, the parenthesis after the function name are required.
VAX C provides a library of common functions. These functions perform standard I/O operations, character and string handling, mathematical operations, miscellaneous system services, and UNIX* system emulation.
For more information, see HELP CC RUN-TIME_FUNCTIONS.
---------- * UNIX is a registered trademark of American Telephone and Telegraph Company.
Builtin_Functions
Built-in functions allow you to directly access the VAX hardware
and machine instructions to perform operations that are cumbersome,
slow, or impossible in pure C.
These functions are very efficient because they are built into the VAX C compiler. This means a call to one of these functions does not result in a reference to a function in the C run-time library or in the user's program. Instead, the compiler generates the machine instructions necessary to carry out the function directly at the call site. Because most of these built-in functions closely correspond to single VAX machine instructions, the result is small, fast code.
Some of these functions (such as those that operate on strings or bits) are of general interest. Others (such as the functions dealing with process context) are of interest if you are writing device drivers or other privileged software. Some of the functions are privileged and unavailable to user mode programs.
The following pragma must occur in the source file before you can use a built-in function:
#pragma builtins
Some of the built-in functions have optional arguments or allow a particular argument to have one of many different types. To describe the different legal combinations of arguments, the description of each built-in function may list several different prototypes for the function. As long as a call to a built-in function matches one of the prototypes listed, the call is legal. Furthermore, any legal call to a built-in function acts as if the corresponding prototype was in scope, so the compiler performs the argument checking and argument conversions specified by that prototype.
The majority of the built-in functions are named after the VAX instruction that they generate. For more information on these built-in functions, see the documentation on the corresponding machine instruction. In particular, see that reference for the structure of queue entries manipulated by the queue built-in functions.
Additional Information on:
The function header va_alist, the definition va_dcl, and the type va_list are used to declare the argument list and the variable that is used to traverse the list.
o The header va_alist is a parameter in the function definition.
o The definition va_dcl declares the parameter va_alist (va_dcl is a definition that is not terminated with a semicolon (;)).
o The type va_list declares the variable used to traverse the list. You must declare at least one incrementing variable of type va_list when using varargs.
The syntax of these headers and declarations is as follows:
function_name(va_alist); va_dcl va_list list_incrementor;
There are five RTL macros used to manipulate variable length argument lists. To use them, you must include the varargs definition module. The five functions are as follows:
va_start The va_start macro initializes the variable list_incrementor to the beginning of the argument list. For more information, see HELP CC RUN-TIME_FUNCTIONS VA_START.
va_start_1 The va_start_1 macro initializes the variable list_incrementor to the beginning of the argument list if there are other arguments that precede the variable length argument list. For more information, see HELP CC RUN-TIME_FUNCTIONS VA_START_1.
va_arg The va_arg macro returns the next item in the argument list. The function must determine the type of the returned item. For more information, see HELP CC RUN-TIME_FUNCTIONS VA_ARG.
va_count The va_count macro returns the number of longwords contained in the argument list. The function is responsible for knowing whether or not a single argument is larger than a single longword. For more information, see HELP CC RUN-TIME_FUNCTIONS VA_COUNT.
va_end The va_end macro terminates the varargs session. You may traverse an argument list more than once. For more information, see HELP CC RUN-TIME_FUNCTIONS VA_END.
Preprocessor
The VAX C preprocessor uses directives to affect the compilation of
a source file. In VAX C, these directives are processed by an
early phase of the compiler, not by a separate program.
The preprocessor directives begin with a number sign (#) and do not end with a semicolon. The number sign must appear in the first column of the source line.
Additional Information on:
The VAX C compiler has predefined tokens and macros for use in programs.
Additional Information on:
Any valid expression or declaration terminated by a semicolon is considered a statement. The statements that control program flow are described in further HELP frames.
See also HELP CC LANGUAGE_TOPICS DECLARATION and HELP CC LANGUAGE_TOPICS PREPROCESSOR.
Additional Information on:
Auto variables are allocated at run time. They are not preserved across functions. Auto is the default storage class for variables declared within a function.
Extern variables are allocated at compile time. They are preserved across functions. There can be only 65,532 extern variables per program. Extern is the default storage class for variables declared outside a function.
Globaldef, globalref, and globalvalue variables are allocated at compile time. They are preserved across functions. The number of global symbols is unlimited.
Register variables are allocated at run time. They cannot be referenced from other separately compiled functions.
Static variables are allocated at compile time. If externally declared, they retain their values across functions. If internally declared (inside of a function), they cannot be referenced from other functions; if control passes from the defining function, to other functions, and then passed back to the defining function, the variable retains its previous value and is not reinitialized.
Data_type_modifiers
Data-type modifiers affect the allocation or access of data
storage. The data-type modifiers are const and volatile.
Additional Information on:
modifier storage_class_keyword identifier;
The modifiers can be used alone; in this case, the default storage class is extern.
Additional Information on: