|
|
HP C
|
Previous | Contents | Index |
a = b + c - d; |
a = b + (c - d); |
/CHECK=POINTER_SIZE directs the compiler to generate code that checks 64-bit pointer values (used in certain contexts where 32-bit pointers are also present) to make sure they will fit in a 32-bit pointer. If such a value cannot be represented by a 32-bit pointer, the run-time code signals a range error (SS$_RANGEERR).
To control the types of pointer-size checks you want made, use one or more of the POINTER_SIZE option keywords shown in Table 1-5.
Specifying /CHECK=POINTER_SIZE defaults to /CHECK=POINTER_SIZE=(ASSIGNMENT,PARAMETER).
For information about compiler features that affect pointer size, see the following:
The following contrived program contains a number of pointer assignments. The comment on each line indicates what /CHECK=POINTER_SIZE keyword to specify to enable checking for that line.
#pragma required_pointer_size long int *a; char *b; typedef char * l_char_ptr; #pragma required_pointer_size short char *c; int *d; foo(int * e) /* Check e if PARAMETER is specified. */ { d = a; /* Check a if ASSIGNMENT is specified. */ c = (char *) a; /* Check a if CAST is specified. */ c = (char *) d; /* No checking ever. */ foo( a ); /* Check a if ASSIGNMENT is specified. */ bar( a ); /* No checking ever - no prototype */ b = (l_char_ptr) a; /* No checking ever. */ c = (l_char_ptr) a; /* Check a if ASSIGNMENT is specified */ b = (char *) a; /* Check if CAST is specified. */ } |
/CHECK=[NO]ARG_INFO (I64 ONLY)
/CHECK=ARG_INFO generates code to verify the input parameters to functions defined in the compiled source. This code checks for datatype consistency between the caller and its called function.
When the runtime does parameter-type checking, only the following types are considered:
VAX single-precision floating-point
VAX double-precision floating-point - D_floating
VAX double-precision floating-point - G_floating
IEEE single-precision floating-point
IEEE double-precision floating-point
none-of-the-above "bucket"
It is only a mismatch of these types that is considered. So while the run-time code will catch a case of a VAX D_floating number passed to a function that expects a VAX single-precision number, it will not detect the case of an int passed to a function that expects a long double type (because both int and long double are viewed as the same type - that is, they both fall into the none-of-the-above bucket).
When a mismatch is found, a %SYSTEM-I-ARGTYP1 message is output at runtime for each argument slot whose type does not match the expected type.
This checking applies only to arguments passed in the first eight argument slots, and does not check that the number of arguments passed matches the number expected.
/CHECK=FP_MODE generates code in the prologue of every function defined in the compilation to compare the current values of certain fields in the processor's floating-point status register (FPSR) with the values expected in those fields based on the command-line qualifiers with which the function was compiled.
The values checked are the rounding mode and the trap-enable bits:
Note that the checking code generated for /CHECK=FP_MODE includes a standard call to OTS$CHECK_FP_MODE within the prologue of each function, and OTS$CHECK_FP_MODE itself assumes the standard calling conventions (described in the OpenVMS Calling Standard). Because of this, it is not possible to use this checking option when compiling function definitions that have a nonstandard linkage (see #pragma linkage and #pragma use_linkage ) specifying conventional scratch registers with the PRESERVED or NOTUSED attribute. Doing so will cause the compiler to issue the "REGCONFLICT" E-level diagnostic at the opening brace of such function definitions. To compile such functions successfully, the FP_MODE keyword must be removed from the list of /CHECK= keywords.
Omitting this qualifier defaults to /NOCHECK, which equates to /CHECK=(NOUNINITIALIZED_VARIABLE,NOBOUNDS,NOPOINTER_SIZE,NOFP_MODE,NOARG INFO).
Specifying /CHECK defaults to /CHECK=(UNINITIALIZED_VARIABLES,BOUNDS, POINTER_SIZE=(ASSIGNMENT,PARAMETER),FP_MODE,ARG_INFO).
Table 1-6 shows the /COMMENTS qualifier options.
Option | Usage |
---|---|
AS_IS | Specifies that the comment appears in the output file. |
SPACE | Specifies that a single space replaces the comment in the output file. |
/NOCOMMENTS specifies that nothing replaces the comment in the output file. This can result in inadvertent token pasting.
The HP C preprocessor might replace a comment at the end of a line or on a line by itself with nothing, even if /COMMENTS=SPACE is specified. Doing so does not change the meaning of the program.
The default is /COMMENTS=SPACE for the ANSI89, RELAXED, and MIA modes of the compiler. The default is /NOCOMMENTS for all other compiler modes.
Specifying /COMMENTS on the command line defaults to /COMMENTS=AS_IS.
If you specify /CROSS_REFERENCE, the compiler lists, for each variable referenced in the procedure, the line numbers of the lines on which the variable is referenced.
This qualifier has no effect unless you also specify /LIST and either /SHOW=SYMBOLS or /SHOW=BRIEF. The default is /NOCROSS_REFERENCE.
If the /DEBUG qualifier is not specified, the default is:
Specifying /DEBUG with no keywords is equivalent to specifying /DEBUG=ALL.
Table 1-7 describes the debugger options.
On OpenVMS VAX systems, the CC command is used to invoke either the VAX C or HP C compiler. If your system has a VAX C compiler already installed on it, the HP C installation procedure provides the option of specifying which compiler will be invoked by default when just the CC command is used. To invoke the compiler that is not the default, use the CC command with the appropriate qualifier: CC/DECC for the HP C compiler, or CC/VAXC for the VAX C compiler. If your system does not have a VAX C compiler installed on it, the CC command will invoke the HP C compiler.
On OpenVMS Alpha and I64 systems, specifying /DECC is equivalent to not specifying it; this qualifier is supported to provide compatibility with HP C on OpenVMS VAX systems.
Since /DEFINE and /UNDEFINE are not part of the source file, they are not associated with a listing line number or source line number. Therefore, when an error occurs in a command-line definition, the message displayed at the terminal does not indicate a line number. In the listing file, these diagnostic messages are placed before the source listing in the order that they were encountered. When the expansion of a definition causes an error at a specific source line in the program, the diagnostics---both at the terminal and in the listing file---are associated with that source line.
A command line containing the /DEFINE and the /UNDEFINE qualifiers can be long. Continuation characters cannot appear within quotes or they will be included in the macro stream. The length of a CC command line cannot exceed the maximum length allowed by DCL.
The /NODEFINE and /NOUNDEFINE qualifiers are provided for compatibility with other DCL qualifiers. You can use these qualifiers to cancel /DEFINE or /UNDEFINE qualifiers that you have specified in a symbol that you use to compile HP C programs.
The defaults are /NODEFINE and /NOUNDEFINE.
Since the CC command line must be compatible with DCL, the syntax of the /DEFINE and /UNDEFINE qualifiers differs from the syntax of the #define and #undef preprocessor directives in the following way:
$ CC/DEFINE=TRUE #define TRUE 1 |
$ CC/DEFINE=MAYBE=2 #define MAYBE 2 |
$ CC/DEFINE=true #define TRUE 1 |
$ CC/DEFINE="true" ! Preserves lowercase $ CC/DEFINE="blank=' '" ! Contains and preserves the blank $ CC/DEFINE="f1=a+b" ! Contains a '+' character $ CC/DEFINE="funct(a)=2" ! Defines a function-like macro |
$ CC/DEFINE="true=1" #define true 1 |
$ CC/DEFINE="true =1" #define true =1 |
$ CC/DEFINE= TRUE $ CC/DEFINE=(FALSE 0) |
You can pass an equal sign to the compiler in any of the following ways:
$ CC/DEFINE=(EQU==,"equ =","equal==") |
In the first definition, the first equal sign is removed by DCL as the delimiter; the second equal sign is passed to the compiler. In the second example, the space is recognized as a delimiter because the definition is inside quotes; therefore, only one equal sign is required. In the third definition, the first equal sign is recognized as the delimiter and is removed; the second equal sign is passed to the compiler.
You can pass quotation marks in any of the following ways:
$ CC/DEFINE=(QUOTES="""","funct(b)=printf(")") |
In both examples, DCL removes the first and last quotation marks before passing the definition to the compiler.
Here is a simple use of the /UNDEFINE qualifier to cancel a previous definition of TRUE:
$ CC/UNDEFINE=TRUE |
The /UNDEFINE qualifier is useful for undefining the predefined HP C preprocessor constants. For example, if you use a preprocessor system identification macro (such as __vaxc , __VAXC , __DECC , or __vms ) to conditionally compile segments of HP C specific code, you can undefine that constant to see how the portable sections of your program execute. Consider the following program:
main() { #if __DECC printf("I'm being compiled with HP C on an OpenVMS system."); #else printf("I'm being compiled on some other compiler."); #endif } |
This program produces the following output:
$ CC EXAMPLE.C[Return] $ LINK EXAMPLE.OBJ[Return] $ RUN EXAMPLE.EXE[Return] I'm being compiled with HP C on an OpenVMS system. $ CC/UNDEFINE="__DECC" EXAMPLE [Return] $ LINK EXAMPLE.OBJ[Return] $ RUN EXAMPLE.EXE[Return] I'm being compiled on some other compiler. |
It controls whether big or little endian ordering of bytes is carried out in character constants. For example, consider the following declaration:
int foo = 'ABCD'; |
Specifying /ENDIAN=LITTLE places 'A' in the first byte, 'B' in the second byte, and so on.
Specifying /ENDIAN=BIG places 'D' in the first byte, 'C' in the second byte, and so on.
The default is /ENDIAN=LITTLE.
The default is /ERROR_LIMIT=30, which specifies that compilation terminates after 31 error messages.
For example, assume the command line contains the following qualifiers:
/EXTERN_MODEL=STRICT_REFDEF="MYDATA"/NOSHARE |
The compiler will behave as if the program begins with the following line:
#pragma extern_model strict_refdef "MYDATA" noshr |
Table 1-8 describes the /EXTERN_MODEL qualifier options.
The default is /EXTERN_MODEL=RELAXED_REFDEF. This is different from VAX C, which uses the common block model for external objects.
This qualifier is useful if you have command lines to pass to the C compiler that are exceeding the DCL command-line length limit. Using the /FIRST_INCLUDE qualifier can help solve this problem by replacing lengthy /DEFINE and /WARNINGS qualifiers with #define and #pragma message preprocessor directives placed in a /FIRST_INCLUDE file.
When /FIRST_INCLUDE=file is specified, file is included in the source as if the line before the first line of the source was:
#include "file" |
If more than one file is specified, the files are included in their order of appearance on the command line.
The default is /NOFIRST_INCLUDE.
Table 1-9 describes the /FLOAT qualifier options.
Previous | Next | Contents | Index |
|