United States    
COMPAQ STORE | PRODUCTS |
SERVICES | SUPPORT | CONTACT US | SEARCH
Compaq C

Compaq C
User's Guide for OpenVMS Systems


Previous Contents Index

On OpenVMS VAX systems, the CC command is used to invoke either the VAX C or Compaq C compiler. If your system has a VAX C compiler already installed on it, the Compaq 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 Compaq 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 Compaq C compiler.

On OpenVMS Alpha systems, specifying /DECC is equivalent to not specifying it; this qualifier is supported to provide compatibility with Compaq C on OpenVMS VAX systems.

/[NO]DEFINE=(identifier[=definition][,...])

/[NO]UNDEFINE=(identifier[,...])

Performs the same functions as the #define and #undef preprocessor directives. The /DEFINE qualifier defines a macro to be substituted for every occurrence of a given identifier in the compilation unit or units. The /UNDEFINE qualifier cancels a previous definition (but not subsequent ones). When both /DEFINE and /UNDEFINE are present in a compilation unit or on the CC command line, /DEFINE is evaluated before /UNDEFINE.

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 Compaq C programs.

The defaults are /NODEFINE and /NOUNDEFINE.

Usage and Examples

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:

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 Compaq 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 Compaq 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 Compaq 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 Compaq 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.

/[NO]DIAGNOSTICS[=file-spec]

Creates a file containing compiler messages and diagnostic information. The default file extension for a diagnostics file is .DIA. The diagnostics file is used with the DIGITAL Language-Sensitive Editor (LSE). To display a diagnostics file, enter the command REVIEW/FILE=file-spec while in LSE. For more information, see Appendix C. The default is /NODIAGNOSTICS.

/ENDIAN=option (ALPHA ONLY)

This qualifier takes the options BIG or LITTLE.

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.

/[NO]ERROR_LIMIT[=n]

This qualifier limits the number of Error-level diagnostic messages that are acceptable during program compilation. Compilation terminates when the limit n is exceeded. /NOERROR_LIMIT specifies that there is no limit on error messages.

The default is /ERROR_LIMIT=30, which specifies that compilation terminates after 31 error messages.

/EXTERN_MODEL=option

In conjunction with the /[NO]SHARE_GLOBALS qualifier, controls the initial compiler model for external objects. Conceptually, the compiler behaves as if the first line of the program being compiled was a #pragma extern_model with the model and psect name, if any, specified by the /EXTERN_MODEL qualifier and with the shr or noshr keyword specified by the /[NO]SHARE_GLOBALS qualifier.

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-7 describes the /EXTERN_MODEL qualifier options.

Table 1-7 /EXTERN_MODEL Qualifier Options
Option Usage
COMMON_BLOCK Sets the compiler's extern_model to the common_block model. This is the model traditionally used for extern data by VAX C.
RELAXED_REFDEF Sets the compiler's extern_model to the relaxed_refdef model. Some declarations are references and some are definitions. Multiple uninitialized definitions for the same object are allowed and are resolved into one by the linker. However, a reference requires that at least one definition exist.

This is the model used by the portable C compiler ( pcc ) on UNIX systems.

STRICT_REFDEF [=" name"] Sets the compiler's extern_model to the strict_refdef model. Some declarations are references and some are definitions. There must be exactly one definition in the program for any symbol referenced. The optional name, in quotation marks, is the name of the psect for any definitions.

This is the model specified by ANSI C. Use it in a program that is to be a strict ANSI C conforming program.

This model is the preferred alternative to the nonstandard storage-class keywords globaldef and globalref .

GLOBALVALUE Sets the compiler's extern_model to the globalvalue model. This model is similar to the strict_refdef model except that these global objects have no storage; instead, they are link-time constant values. There are two cases:
  • If the declaration is an ANSI C reference, the same object file records are produced as VAX C would produce for an uninitialized globalvalue .
  • If the declaration is an ANSI C definition, the same object records are produced as VAX C would produce for an initialized globalvalue .

This model is the preferred alternative to the nonstandard storage-class keyword globalvalue .

The default is /EXTERN_MODEL=RELAXED_REFDEF. This is different from VAX C, which uses the common block model for external objects.

/FLOAT=option

Controls the format of floating-point variables.

On OpenVMS Alpha systems, representation of double variables defaults to G_floating format if not overridden by another format specified with the /FLOAT or /[NO]G_FLOAT qualifier.

If you are linking against object-module libraries, and /PREFIX=ALL is not specified on the command line:

The VAXCRTLX.OLB, VAXCRTLDX.OLB, and VAXCRTLTX.OLB libraries are used for the same floating-point formats, respectively, but include support for X_FLOAT format (/L_DOUBLE_SIZE=128). (ALPHA ONLY)

If /PREFIX=ALL is specified, then there is no need to link to the above-mentioned *.OLB object libraries. All the symbols you need are in STARLET.OLB. (ALPHA ONLY)

On OpenVMS VAX systems, representation of double variables defaults to D_floating format if not overridden by another format specified with the /FLOAT or /[NO]G_FLOAT qualifier. There is one exception: if /STANDARD=MIA is specified, G_floating is the default. If you are linking against object-module libraries, a program compiled with G_floating format must be linked with the object library DECCRTLG.OLB. (VAX ONLY)

Table 1-8 describes the /FLOAT qualifier options.

Table 1-8 /FLOAT Qualifier Options
Option Usage
D_FLOAT double variables are represented in D_floating format.
G_FLOAT double variables are represented in G_floating format.
IEEE_FLOAT (ALPHA ONLY) float and double variables are represented in IEEE floating-point format (S_float and T_float, respectively). Use the /IEEE_MODE qualifier for controlling the handling of IEEE exceptional values. If /IEEE_MODE is not specified, the default behavior is /IEEE_MODE=FAST.

/[NO]G_FLOAT

Controls the format of floating-point variables. The /[NO]G_FLOAT qualifier is replaced by the /FLOAT qualifier, but is retained for compatibility.

If you specify /G_FLOAT, double variables are represented in G_floating format.

If you specify /NOG_FLOAT, double variables are represented in D_floating format. (See Section 4.5 for more information on the floating formats.)

On OpenVMS Alpha systems, representation of double variables defaults to G_floating format if not overridden by another format specified with the /FLOAT or /[NO]G_FLOAT qualifier.

If you are linking against object-module libraries, and /PREFIX=ALL is not specified on the command line:

The VAXCRTLX.OLB, VAXCRTLDX.OLB, and VAXCRTLTX.OLB libraries are used for the same floating-point formats, respectively, but include support for X_FLOAT format (/L_DOUBLE_SIZE=128). (ALPHA ONLY)

If /PREFIX=ALL is specified, then there is no need to link to the above-mentioned *.OLB object libraries. All the symbols you need are in STARLET.OLB. (ALPHA ONLY)

On OpenVMS VAX systems, representation of double variables defaults to D_floating format if not overridden by another format specified with the /FLOAT or /[NO]G_FLOAT qualifier. There is one exception: if /STANDARD=MIA is specified, G_floating is the default. If you are linking against object-module libraries, a program compiled with G_floating format must be linked with the object library DECCRTLG.OLB. (VAX ONLY)

/GRANULARITY=option (ALPHA ONLY)

Determines how much memory to effectively cache for memory reference, depending on the compiler and the underlying system. For example, quadword granularity may require that the system cache quadword values in registers. If access to data in the same granularity unit occurs simultaneously, corruption (by storing back stale values) can occur.

Granularity has two aspects: references inside a particular data segment and references between data segments.

The options are:

BYTE
LONGWORD
QUADWORD

The default is /GRANULARITY=QUADWORD.

/IEEE_MODE=option (ALPHA ONLY)

Selects the IEEE floating-point mode to be used if /FLOAT=IEEE_FLOAT is specified.

Table 1-9 describes the /IEEE_MODE options.

Table 1-9 /IEEE_MODE Options
Option Usage
FAST During program execution, only finite values (no infinities, NaNs, or denorms) are created. Underflows and denormal values are flushed to zero. Exceptional conditions, such as floating-point overflow, divide-by-zero, or use of an IEEE exceptional operand are fatal. This is the default option.
UNDERFLOW_TO_ZERO Generate infinities and NaNs. Flush denormalized results and underflow to zero without exceptions.
DENORM_RESULTS Same as UNDERFLOW_TO_ZERO, except that denorms are generated.
INEXACT Same as DENORM_RESULTS, except that inexact values are trapped. This is the slowest mode, and is not appropriate for any sort of general-purpose computations.

The default is /IEEE_MODE=FAST.

/[NO]INCLUDE_DIRECTORY=(pathname[,...])

Provides similar functionality to the -i option of the cc command on Tru64 UNIX systems. This qualifier allows you to specify additional places to search for include files. A place can be one of the following:

If one of the places is specified as an empty string, the compiler does not search any of its conventionally-named places:

DECC$USER_INCLUDE
DECC$SYSTEM_INCLUDE
DECC$LIBRARY_INCLUDE
SYS$COMMON:[DECC$LIB.INCLUDE.*]
DECC$TEXT_LIBRARY
SYS$LIBRARY:DECC$RTLDEF.TLB
SYS$LIBRARY:SYS$STARLET_C.TLB

Instead, it searches only places specified explicitly on the command line by the /INCLUDE_DIRECTORY and /LIBRARY qualifiers (or by the location of the primary source file, depending on the /NESTED_INCLUDE_DIRECTORY qualifier). This behavior is similar to that obtained by specifying -I without a directory name to the Tru64 UNIX cc command.

The basic search order depends on the form of the header-file name (after macro expansion). Additional aspects of the search order are controlled by other command-line qualifiers and the presence or absence of logical name definitions.

Only the portable forms of the #include directive are affected by the pathnames specified on an /INCLUDE_DIRECTORY qualifier:

However, an empty string also affects the text-module form specific to OpenVMS systems (example: #include stdio ).

Except where otherwise specified, searching a "place" means that the string designating the place is used as the default file-spec in a call to an RMS system service (for example, $SEARCH/$PARSE). The file-spec consists of the name in the #include directive without enclosing delimiters. The search terminates successfully as soon as a file can be opened for reading.

Note

Prior to OpenVMS VAX Version 7.1, the operating system did not provide a SYS$LIBRARY:SYS$STARLET_C.TLB nor the headers contained therein. Instead, the compiler installation generated these headers and placed them in SYS$LIBRARY:DECC$RTLDEF.TLB.

Quoted Form

For the quoted form of inclusion, the search order is:

  1. One of the following:
  2. Search the places specified in the /INCLUDE_DIRECTORY qualifier, if any. A place that can be parsed successfuly as an OpenVMS file-spec and that does not contain an explicit file type or version specification is edited to append the default header file type specification (".h" or ".").
    A place containing a "/" character is considered to be a UNIX-style name. If the name in the #include directive also contains a "/" character that is not the first character and is not preceded by a "!" character (it is not an absolute UNIX-style pathname), then the name in the #include directive is appended to the named place, separated by a "/" character, before applying the decc$to_vms pathname translation function. The result of the decc$to_vms translation is then used as the filespec to try to open.
  3. If DECC$USER_INCLUDE is defined as a logical name, search DECC$USER_INCLUDE:.H, or just DECC$USER_INCLUDE:. if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
  4. If the file is not found, follow the steps for the angle-bracketed form of inclusion.

Angle-Bracketed Form

For the angle-bracketed form of inclusion, the search order is:

  1. Search the place "/". This is a UNIX-style name that can combine only with UNIX names specified explicitly in the #include directive. It causes a specification like <sys/types.h> to be considered first as /sys/types.h, which is translated by decc$to_vms to SYS:TYPES.H.
  2. Search the places specified in the /INCLUDE_DIRECTORY qualifier, exactly as in Step 2 for the quoted form of inclusion.
  3. If DECC$SYSTEM_INCLUDE is defined as a logical name, search DECC$SYSTEM_INCLUDE:.H, or just DECC$SYSTEM_INCLUDE:. if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
  4. If DECC$LIBRARY_INCLUDE is defined as a logical name and DECC$SYSTEM_INCLUDE is not defined as a logical name, search DECC$LIBRARY_INCLUDE:.H, or just DECC$LIBRARY_INCLUDE:. if /ASSUME=NOHEADER_TYPE_DEFAULT is in effect.
  5. If neither DECC$LIBRARY_INCLUDE nor DECC$SYSTEM_INCLUDE are defined as logical names, then search the default list of places for plain text-file copies of compiler header files as follows:
    SYS$COMMON:[DECC$LIB.INCLUDE.DECC$RTLDEF].H
    SYS$COMMON:[DECC$LIB.INCLUDE.SYS$STARLET_C].H

    Note

    The compiler installation does not create these directories of header files. Instead, it creates [DECC$LIB.REFERENCE] for your convenience. But if you choose to create and populate SYS$COMMON:[DECC$LIB.INCLUDE.DECC$RTLDEF] or SYS$COMMON:[DECC$LIB.INCLUDE.SYS$STARLET_C].H, the compiler will search them.

    If the file is not found, perform the text library search described in the next step.
  6. Extract the simple filename and file type from the #include specification and use the filename as the module name to search a list of text libraries associated with that file type.
    For any file type, the initial text libraries searched consist of those named on the command line with /LIBRARY qualifiers, searched in left-to-right order.
    If the /INCLUDE_DIRECTORY qualifier contained an empty string, no further text libraries are searched. Otherwise, DECC$TEXT_LIBRARY is searched for all file types.
    If DECC$LIBRARY_INCLUDE is defined as a logical name, then no further text libraries are searched. Otherwise, the subsequent libraries searched for each file type are:
  7. If the previous step fails, search the following:
    SYS$LIBRARY:.H

    Under /ASSUME=NOHEADER_TYPE_DEFAULT, the default file type is modified as usual.


Previous Next Contents Index
  

1.800.AT.COMPAQ

privacy and legal statement