United States

Compaq C

# Compaq C
User's Guide for OpenVMS Systems

Previous | Contents | Index

## 1.3.1 The CC Command

To invoke the Compaq C compiler, enter the CC command at the DCL prompt ($). The CC command has the following format:

`CC[/qualifier...][ file-spec [/qualifier...]],...`

Note (VAX ONLY) This note applies to OpenVMS VAX systems that have both Compaq C and VAX C installed. The CC command is used to invoke either the VAX C or Compaq C compiler. If the Compaq C installation procedure detects that your system already has a VAX C compiler installed on it, the installer is given the option to specify which compiler gets invoked by default whenever the CC command verb 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. Where the CC command appears in examples in this manual, CC/DECC is assumed to be the default.

> ### /qualifier

> An action to be performed by the compiler on all files or specific files listed. When a qualifier appears directly after the CC command, it affects all the files listed. When a qualifier appears after a file specification, it affects only the file that immediately precedes it. However, when files are concatenated, these rules do not apply.

> ### file-spec

> An input source file that contains the program or module to be compiled. You are not required to specify a file type if you give your file a .C file extension; the Compaq C compiler adopts the default file type C.

You can include more than one file specification on the same command line by separating the file specifications with either a comma (,) or a plus sign (+). If you separate the file specifications with commas, you can control which source files are affected by each qualifier. In the following example, the Compaq C compiler creates an object file for each source file but creates only a listing file for the source files PROG_1 and PROG_3:

    $ CC /LIST PROG_1, PROG_2/NOLIST, PROG_3

If you separate file specifications with plus signs, the Compaq C compiler concatenates each of the specified source files and creates one object file and one listing file. In the following example, only one object file is created, PROG_1.OBJ, and only one listing file is created, PROG_1.LIS. Both of these files are named after the first source file in the list, but contain all three modules.

    $ CC PROG_1 + PROG_2/LIST + PROG_3

Any qualifiers specified for a single file within a list of files separated with plus signs affect all the files in the list. See the description of the /PLUS_LIST_OPTIMIZE qualifier for its affect on file concatenation.

Note Concatenating source files without using the /PLUS_LIST_OPTIMIZE qualifier (ALPHA ONLY) is not recommended because potential conflicts in the name space of declared objects can result in compilation errors or incorrect run-time behavior.

A more common use of plus-list concatenation is for specifying text libraries. You can specify the name of a text library on the CC command line to compile a source program. A text library is a file that contains text organized into modules indexed by a table. Text libraries have a .TLB default file extension. In the following example, text libraries A.TLB and B.TLB are made available for searching for text library modules during the compilation of source file TEST.C:

    $ CC TEST.C + A.TLB/LIB + B.TLB/LIB

### 1.3.1.1 Including Header Files

Header files are pieces of source code that typically contain declarations shared among C programs. A header file often declares a set of related functions, as well as defining any types and macros needed for their use.

To make the contents of a header file available to your program, include the header file using the `#include` preprocessor directive.

The `#include` directive has three forms. Two of the forms are defined by the ISO C standard and are portable:

- Inclusion using angle brackets to delimit the file to be included:

  `#include <file-spec>`

- Inclusion using quotation marks to delimit the file to be included:

  `#include "file-spec"`

The third form is the text-module form. It is specific to OpenVMS systems and is not portable. See Section 5.2.3 for more information on the text-module form of inclusion.

The form of the `#include` directive used determines where the compiler will look to find the file to be included. Generally, the compiler looks in the following places, in the order listed:

1. Places named on the command line with the /INCLUDE_DIRECTORY qualifier or the /LIBRARY qualifier
2. Places identified through logical names, such as DECC$USER_INCLUDE, DECC$SYSTEM_INCLUDE, DECC$LIBRARY_INCLUDE, and DECC$TEXT_LIBRARY
3. System-defined places such as the SYS$COMMON:[DECC$LIB.INCLUDE.*] directory and the SYS$LIBRARY:DECC$RTLDEF.TLB and SYS$LIBRARY:SYS$STARLET_C.TLB text libraries

You can use the UNUSED message group described in the `#pragma message` description in Section 5.4.12 to enable messages that report apparently unnecessary `#include` files (and CDD records). Unlike any other messages, these messages must be enabled on the command line (/WARNINGS=ENABLE=UNUSED), rather than with `#pragma message` , to be effective.

The Compaq C preprocessor is usually able to determine if a particular `#include` file that has already been processed once was guarded by the conventional sequence: `#ifndef FILE_SEEN, #define FILE_SEEN, #endif` .

When the compiler detects this pattern of use the first time a particular file is included, it remembers that fact as well as the name of the macro. The next time the same file is included, the compiler checks to see if the "FILE_SEEN" macro is still defined and, if so, it does not reopen and reread the file. Note that if the initial test is in the form `#if !defined` instead of `#ifndef` , then the pattern is not recognized. In a listing file, `#include` directives that are skipped because of this processing are marked with an "X" just as if the `#include` line itself were excluded.

See the /INCLUDE_DIRECTORY qualifier in Section 1.3.4 for a more complete description of the search-order rules that Compaq C uses to locate included files.

See the Compaq C Run-Time Library Reference Manual for OpenVMS Systems for information on the header files required to use Compaq C Run-Time Library (RTL) functions and macros.

### 1.3.1.2 Listing Header Files

To list the names of system header files, use the following commands:

    $ LIBRARY/LIST SYS$LIBRARY:SYS$STARLET_C.TLB
    (OpenVMS Alpha and OpenVMS VAX Version 7.1 and higher)

    $ LIBRARY/LIST SYS$LIBRARY:DECC$RTLDEF.TLB

    $ DIR SYS$COMMON:[DECC$LIB.REFERENCE.SYS$STARLET_C]*.H;

    $ DIR SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF]*.H;

    $ DIR SYS$LIBRARY:*.H;

These commands list, respectively:

- The names of the text-module header files for the OpenVMS system interfaces
- The names of the text-module header files for the Compaq C language interfaces
- *.h header files for the OpenVMS system interfaces
- *.h header files for the Compaq C language interfaces
- *.h header files for layered products and other applications

Note The SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF] and SYS$COMMON:[DECC$LIB.REFERENCE.SYS$STARLET_C] directories are only reference areas for your viewing. They are created during the compiler installation from the content of the text libraries. By default, the compiler searches only the text library files for headers; it does not search these reference directories.

Be aware that OpenVMS VAX operating systems prior to Version 7.1 do not have a file named SYS$LIBRARY:SYS$STARLET_C.TLB. For these older versions of the operating system, the STARLET header files are generated during Compaq C installation and placed in SYS$LIBRARY:DECC$RTLDEF.TLB and also in both SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF] and SYS$COMMON:[DECC$LIB.REFERENCE.SYS$STARLET_C].

## 1.3.2 Compilation Modes

Compaq C has two complementary qualifiers that control which dialect of C is to be recognized by the compiler, and which messages are generated:

- The /STANDARD qualifier controls what language features and extensions are recognized by the compiler.
- The /[NO]WARNINGS qualifier enables or disables the generation of warning and/or informational messages.

The /STANDARD qualifier causes the compiler to issue only those warnings appropriate for the dialect of C being compiled. For example, VAX C compatibility mode (/STANDARD=VAXC) does not issue warnings against VAX C extensions, while ANSI C mode does.

To generate a list of all messages that are in effect at the start of compilation, specify /LIST/SHOW=MESSAGES. For each message, the identifier, severity, and message text are shown. To also show the message description and user action for each message listed, specify /LIST/SHOW=MESSAGES/WARN=VERBOSE.

The Compaq C compiler for OpenVMS systems provides several dialects of C, which are controlled by the /STANDARD qualifier:

- Strict ANSI C: Only the ANSI C Standard 89 (C89) language dialect is recognized. This mode is enabled by specifying /STANDARD=ANSI89 on the CC command line.
  /STANDARD=ANSI89 issues all diagnostics required by the ANSI C standard as well as a number of optional diagnostics that help detect source code constructs that are not portable under the C89 standard. Digraph recognition from the 1994 Amendment is also supported in this mode.
  You can use /STANDARD=ANSI89 with /[NO]WARNINGS to control issuance of informational or warning messages. However, since the compiler does not recognize many VAX C or common C extensions when in strict ANSI mode (for example, VAX C keywords not beginning with two underscores), many of the messages normally associated with flagging VAX C and common C extensions are not produced.
- Strict C99 (ALPHA ONLY): Only the ISO C99 dialect is recognized. This mode is enabled by specifying /STANDARD=C99 on the CC command line.
  /STANDARD=C99 accepts just the C99 language without extensions, and diagnoses violations of the C99 standard. Because C99 is a superset of Amendment 1 to the C89 standard, and the default mode of RELAXED_ANSI89 is a superset of C99, the __STDC_VERSION__ macro is now defined with the C99-specified value of 199901L. Only when the ISOC94 keyword is added to the strict ANSI89, MIA, or COMMON modes does the macro take on the Amendment 1 value of 199409L (In the absence of the ISOC94 keyword, the ANSI89, MIA, and COMMON modes do not define the macro at all.)

  Note /STANDARD=C99 is not fully supported on VAX systems. Specifying /STANDARD=C99 on OpenVMS VAX systems produces a warning and puts the compiler into /STANDARD=RELAXED_ANSI mode.

- Relaxed ANSI C: This is the default mode on OpenVMS systems, and is specified by /NOSTANDARD or /STANDARD=RELAXED_ANSI89 on the CC command line. The /STANDARD=RELAXED mode accepts ANSI/ISO C Standard C89 and C99 features, as well as nearly all language extensions (such as additional Compaq C keywords and predefined macros that do not begin with an underscore). It excludes only K&R (COMMON mode), VAX C, and Microsoft features that conflict with standard C. The purpose of the /STANDARD=RELAXED mode is to support everything from the most current ISO C standard, in addition to all extensions that do not specify different semantics for the same constructs.
- Microsoft compatibility: This mode interprets source programs according to certain language rules followed by the C compiler provided with the Microsoft Visual C++ compiler product. This mode is enabled by specifying /STANDARD=MS on the CC command line. See Section 1.3.3 for more information about Microsoft compatibility mode.
- ISO C 94: This mode is enabled by specifying /STANDARD=ISOC94. It can be specified alone or with any other /STANDARD option except VAXC. If it is specified alone, the default major mode is RELAXED_ANSI89.
  Specifying /STANDARD=ISOC94 enables digraph processing and defines the predefined macro `__STDC_VERSION__=199409L` , as specified by Amendment 1 to the C89 standard.
- VAX C compatibility: This mode is enabled by specifying /STANDARD=VAXC. It allows the same language as the ANSI C language, but also supports VAX C extensions that are incompatible with the ANSI C Standard and that change the language semantics. This mode provides compatibility for programs that depend on old VAX C behavior.
- Portable: This mode is enabled by specifying /STANDARD=PORTABLE. It places the compiler in RELAXED_ANSI89 mode and enables the issuance of diagnostics that warn about any nonportable usages encountered.
  /STANDARD=PORTABLE is supported for VAX C compatibility only. It is equivalent to the recommended combination of qualifiers /STANDARD=RELAXED_ANSI89/WARNINGS=ENABLE=PORTABLE.
- Common usage C: This mode is enabled by specifying /STANDARD=COMMON. It enforces K & R programming style; that is, compatibility with older UNIX compilers such as `pcc` and `gcc` . This mode is close to a subset of /STANDARD=VAXC mode.
- MIA conformance (VAX ONLY): This mode is enabled by specifying /STANDARD=MIA. This is strict ANSI C with some differences required by the Multivendor Integration Architecture (MIA) standard. Compiling a program with /STANDARD=MIA sets the `__MIA` predefined macro to 1.

With one exception, the /STANDARD qualifier options are mutually exclusive. Do not combine them. The exception is that you can specify /STANDARD=ISOC94 with any other option except VAXC.

Compaq C modules compiled in different modes can be linked and executed together.

The /STANDARD qualifier is further described in Section 1.3.4.

Also see the `__HIDE_FORBIDDEN_NAMES` predefined macro ( Section 6.1.7).

## 1.3.3 Microsoft Compatibility Compilation Mode

The /STANDARD=MS qualifier instructs the Compaq C compiler to interpret your source code according to certain language rules followed by the C compiler provided with the Microsoft Visual C++ compiler product. However, compatibility with this implementation is not complete. The following sections describe the compatibility situations that Compaq C recognizes. In most cases, these situations consist of relaxing a standard behavior and suppressing a diagnostic message.

### 1.3.3.1 Unnamed Nested struct or union Members

Allow a declaration of a structure with no name within another structure. You can reference all members of the inner structure as members of the named outer structure. This is similar to the C++ treatment of nested unions lacking a name, but extended to both structures and unions. A similar capability is provided by the VAX C `variant_struct` and `variant_union` types.

For example:

    struct{
      struct{
          int a;
          int b;
      };  /*No name here */
      int c;
    }d;  /* d.a, d.b, and d.c are valid member names. */

### 1.3.3.2 Block Scope Declaration of static Functions

Allow a `static` function declaration in block scope (that is, inside another function).

For example:

    f(){
       static int a(int b);
    }

### 1.3.3.3 Treat &* as Having No Effect

ANSI C does not allow the `&` operator to produce an lvalue expression. The Microsoft relaxation allows `&` to produce an lvalue in certain cases.

For example:

    int *a, *b;

    f() {

      &*a=b;

    }

### 1.3.3.4 Integer and Pointer Comparisons without a Cast

Allow integers and pointers to be compared without a cast.

For example:

    int *a,b;

    f(){
    if (a==b)
       b=1;
    }

### 1.3.3.5 char is Not Treated as a Unique Type

Treat the `char` type as either `signed char` or `unsigned char` , depending on the default in effect.

For example, a pointer to `char` can be assigned to a pointer to `signed char` , assuming the command-line default of /NOUNSIGNED_CHAR:

    signed char *a;
    char *b;

    f() {
    b=a;
    }

### 1.3.3.6 Double Semicolons in Declarations

Suppress warning messages for declarations that contain two semicolons. (That is, allow completely empty declarations at file scope.)

For example:

    int a;;

### 1.3.3.7 Declaration without a Type

Suppress warning messages for declarations that contain a variable name but no type.

For example:

    b;

### 1.3.3.8 Enumerators in an Enumeration Declaration

Ignore any extra comma at the end of the last enumerator in an enumeration declaration.

For example:

    enum E {a, b, c,};    /*  Ignore the comma after "c". /*

### 1.3.3.9 Useless Typedefs

Allow `typedef` s that have a type specifier but no identifier name declaring the new type.

For example:

    typedef struct { int a; };

### 1.3.3.10 Unrecognized Pragmas Accepted

Suppress warning messages when one of the following unsupported Microsoft pragmas is encountered:

    #pragma code_seg
    #pragma optimize
    #pragma warning

## 1.3.4 CC Command Qualifiers

The following list shows all the command qualifiers and their defaults available with the CC command. A description of each qualifier follows the list.

You can place command qualifiers either on the CC command line itself or on individual file specifications (with the exception of the /LIBRARY qualifier). If placed on a file specification, the qualifier affects only the compilation of the specified source file and all subsequent source files in the compilation unit. If placed on the CC command line, the qualifier affects all source files in all compilation units unless it is overridden by a qualifier on an individual file specification.

Command Qualifiers | Default
--- | ---
/ACCEPT=(option[,option]) | See text.
/[NO]ANALYSIS_DATA[=file-spec] | /NOANALYSIS_DATA
/[NO]ANSI_ALIAS (ALPHA ONLY) | See text.
/ARCHITECTURE=option (ALPHA ONLY) | /ARCHITECTURE=GENERIC
/ASSUME=(option[,...]) | See text.
/[NO]CHECK[=(option,...)] (ALPHA ONLY) | /NOCHECK
/[NO]COMMENTS=option | See text.
/[NO]CROSS_REFERENCE | /NOCROSS_REFERENCE
/[NO]DEBUG[=(option[,...])] | /DEBUG=(TRACEBACK,
| NOSYMBOLS) (ALPHA ONLY)
| /DEBUG=(TRACEBACK,NOINLINE,
| NOSYMBOLS) (VAX ONLY)
/DECC | See text.
/[NO]DEFINE=(identifier[=definition][,...]) | /NODEFINE
/[NO]DIAGNOSTICS[=file-spec] | /NODIAGNOSTICS
/ENDIAN=option (ALPHA ONLY) | /ENDIAN=LITTLE
/[NO]ERROR_LIMIT[=n] | /NOERROR_LIMIT
/EXTERN_MODEL=option | /EXTERN_MODEL=RELAXED_REFDEF
/[NO]FIRST_INCLUDE=(file[,...]) (ALPHA ONLY) | /NOFIRST_INCLUDE
/FLOAT=option | /FLOAT=G_FLOAT (ALPHA ONLY)
| /FLOAT=D_FLOAT (VAX ONLY)
/[NO]G_FLOAT | /G_FLOAT (ALPHA ONLY)
| /NOG_FLOAT (VAX ONLY)
/GRANULARITY=option (ALPHA ONLY) | /GRANULARITY=QUADWORD
/[NO]INCLUDE_DIRECTORY=(pathname[,...]) | /NOINCLUDE_DIRECTORY
/IEEE_MODE=option (ALPHA ONLY) | IEEE_MODE=FAST
/INSTRUCTION_SET=[NO]FLOATING_POINT (ALPHA ONLY) | /INSTRUCTION_SET=FLOATING_POINT
/L_DOUBLE_SIZE=option (ALPHA ONLY) | /L_DOUBLE_SIZE=128
/LIBRARY | See text.
/[NO]LINE_DIRECTIVES | /LINE_DIRECTIVES
/[NO]LIST[=file-spec] | /NOLIST (interactive mode)
| /LIST (batch mode)
/[NO]MACHINE_CODE[=option] | /NOMACHINE_CODE
/[NO]MEMBER_ALIGNMENT | /MEMBER_ALIGNMENT (ALPHA ONLY)
| /NOMEMBER_ALIGNMENT (VAX ONLY)
/[NO]MMS_DEPENDENCIES=option | /NOMMS_DEPENDENCIES
/NAMES=option | /NAMES=UPPERCASE
/NESTED_INCLUDE_DIRECTORY[=option] | /NESTED_INCLUDE_DIRECTORY
| =INCLUDE_FILE
/[NO]OBJECT[=file-spec] | /OBJECT
/[NO]OPTIMIZE[=(option[,...])] | /OPTIMIZE
/PDSC_MASK=option (ALPHA ONLY) | See text.
/[NO]PLUS_LIST_OPTIMIZE (ALPHA ONLY) | /NOPLUS_LIST_OPTIMIZE
/[NO]POINTER_SIZE=option (ALPHA ONLY) | /NOPOINTER_SIZE
/PRECISION[=option] | See text.
/[NO]PREFIX_LIBRARY_ENTRIES |
[=(option[,...])] | See text.
/[NO]PREPROCESS_ONLY[=filename] | /NOPREPROCESS_ONLY
/[NO]PROTOTYPES[=(option[,...])] | /NOPROTOTYPES
/PSECT_MODEL=[NO]MULTILANGUAGE (ALPHA ONLY) | /NOMULTILANGUAGE
/REENTRANCY=option (ALPHA ONLY) | /REENTRANCY=TOLERANT
/REPOSITORY=option | /See text.
/ROUNDING_MODE=option (ALPHA ONLY) | /ROUNDING_MODE=NEAREST
/[NO]SHARE_GLOBALS | /NOSHARE_GLOBALS
/SHOW[=(option[,...])] | /SHOW=(NOBRIEF,
| NOCROSS_REFERENCE,
| NODICTIONARY,
| NOEXPANSION,
| NOINCLUDE,
| NOINTERMEDIATE,
| NOMESSAGE,
| NOSTATISTICS,
| NOSYMBOLS,
| NOTRANSLATION,
| SOURCE,
| TERMINAL)
/[NO]STANDARD[=(option[,...])] | /NOSTANDARD (equivalent to
| /STANDARD=RELAXED_ANSI89 )
/[NO]TIE (ALPHA ONLY) | /NOTIE
/[NO]UNDEFINE=(identifier[,...]) | /NOUNDEFINE
/[NO]UNSIGNED_CHAR | /NOUNSIGNED_CHAR
/VAXC (VAX ONLY) | See text.
/[NO]VERSION | /NOVERSION
/[NO]WARNINGS[=(option[,...])] | /WARNINGS

> ### /ACCEPT=(option[,option])

> Allows the compiler to accept C language syntax that it might not normally accept.

> Previous | Next | Contents | Index

> privacy and legal statement