Skip to Main Content United States    
PRODUCTS SUPPORT SOLUTIONS SERVICES
COMPAQ SOFTWARE
Compaq C

Compaq C
User's Guide for OpenVMS Systems


Previous Contents Index


Appendix A
VAX C to Compaq C Differences

This appendix documents many features that distinguish Compaq C for OpenVMS Systems from VAX C Version 3.2.

This appendix was written for the first release of Compaq C as a guide for installations migrating from VAX C to Compaq C. It is not intended to be a complete compendium of new features for all Compaq C versions. For a summary of new features for the current version of the compiler, see the release notes and the New and Changed Features section in the Preface of this and the other Compaq C manuals. For additional help migrating from VAX C to Compaq C, see the DEC C Migration Guide for OpenVMS VAX Systems (VAX ONLY).

The major focus of Compaq C for OpenVMS Systems is to bring it into full conformance with the ANSI C Standard. The language described by the ANSI C Standard differs in many ways from the language originally implemented by VAX C. These differences include additional language features and constructs, the removal of obsolete features and usages, and a number of other changes that generally involve a tightening up of semantic rules.

Some of the new ANSI C Standard features have already been implemented in previous versions of VAX C. Some of these are: support for function prototypes, the const and volatile type qualifiers, and the void type specifier.

Although every attempt has been made to maintain compatibility with earlier versions of the VAX C compiler, many of the changes required to bring the compiler into conformance with the ANSI C Standard would introduce unavoidable incompatibilities with these earlier versions. For example, VAX C supports a number of language and semantic extensions that are not ANSI-conformant.

Therefore, to provide compatibility with previous versions of the compiler, Compaq C for OpenVMS Systems supports several modes of operation:

  • Strict ANSI C Standard mode, in which all nonstandard constructs and usages (including VAX C extensions) are diagnosed
  • Relaxed ANSI C mode (the default on OpenVMS systems), in which the compiler follows the ANSI C standard but also accepts additional Compaq keywords and predefined macros that do not begin with an underscore
  • VAX C mode, in which as many previously supported features as possible continue to be supported
  • Common mode, in which extensions to the ULTRIX portable C compiler ( pcc ) are supported

Note that some of the language changes dictated by the ANSI C Standard are present in VAX C mode. Some of these changes are quiet changes; that is, they cannot be detected as such by the compiler, so no diagnostic messages are issued. Also note that some extensions are permitted in the strict ANSI C mode. These extensions are diagnosed, but with no greater severity than Warning. Both types of changes are included in the following sections that describe all new and changed features.

A.1 Features Affecting the Compiler

This section describes Compaq C compiler features. ( Section A.2 describes features that affect the Compaq C run-time library and include files.)

A.1.1 Compaq C Qualifiers

Qualifiers new to Compaq C:

  • /[NO]ANSI_ALIAS (ALPHA ONLY)---Directs the compiler to assume the ANSI C aliasing rules. By so doing, the compiler has the freedom to generate better optimized code.
  • /ASSUME=(option,...)---Controls compiler assumptions.
  • /DECC---Invokes the Compaq C compiler. For OpenVMS VAX systems, the default is set to either /DECC or /VAXC during installation.
    For OpenVMS Alpha systems, specifying /DECC is equivalent to not specifying it; it is supported to provide compatibility with Compaq C on OpenVMS VAX systems.
  • /ENDIAN=option (ALPHA ONLY)---Controls whether big or little endian ordering of bytes is carried out in character constants.
  • /EXTERN_MODEL---In conjunction with the /[NO]SHARE_GLOBALS qualifier, controls the initial extern model of the compiler. Also see #pragma extern_model .
  • /FLOAT---Controls the format of floating-point variables. It replaces the /[NO]G_FLOAT qualifier, which is retained for compatibility.
  • /GRANULARITY (ALPHA ONLY)---Determines how much memory to effectively cache for memory reference, by the combination of the compiler and the underlying system.
  • /IEEE_MODE=option (ALPHA ONLY)---Selects the IEEE floating-point mode to be used if /FLOAT=IEEE_FLOAT is specified.
  • /INSTRUCTION_SET=[NO]FLOATING_POINT (ALPHA ONLY)---Suppresses or allows the generation of floating-point instructions for integer operations.
  • /L_DOUBLE_SIZE=option (ALPHA ONLY)---Determines how the compiler interprets the long double type.
  • /[NO]MEMBER_ALIGNMENT---Controls alignment of data structure members. For OpenVMS Alpha systems, the default is /MEMBER_ALIGNMENT, which aligns structure members on the next boundary appropriate to the type of the member. For OpenVMS VAX systems, the default is /NOMEMBER_ALIGNMENT, which aligns structure members on byte boundaries.
  • /NAMES---Converts all definitions and references of external symbols and psects to the specified case (UPPERCASE, LOWERCASE, or AS_IS).
  • /NESTED_INCLUDE_DIRECTORY[=option]---Controls the directories that the compiler searches when looking for nested include files that are included using the quoted form of the #include preprocessor directive.
  • /OPTIMIZE---Determines whether Compaq C performs various code optimizations.
  • /[NO]PLUS_LIST_OPTIMIZE (ALPHA ONLY)---Provides improved optimization and code generation across file boundaries that would not be available if the files were compiled separately.
  • /[NO]PREFIX_LIBRARY_ENTRIES=(option,...)---Controls the Compaq C Run-Time LIbrary (RTL) name prefixing.
  • /REENTRANCY[=option] (ALPHA ONLY)---Controls the type of reentrancy that reentrant Compaq C RTL routines will exhibit. (See also the decc$set_reentrancy RTL routine.)
  • /ROUNDING_MODE=option (ALPHA ONLY)---Lets you select an IEEE rounding mode, if /FLOAT=IEEE_MODE is specified.
  • /[NO]SHARE_GLOBALS---Specifies whether external objects are to be marked share or noshare. Used in conjunction with /EXTERN_MODEL to control the initial extern model of the compiler. Also see the #pragma extern_model preprocessor directive.
  • /[NO]STANDARD---Enhanced to include the following options (in addition to /STANDARD=PORTABLE):
    • ANSI89
    • RELAXED_ANSI89
    • COMMON
    • VAXC
    • MIA
  • /[NO]TIE (ALPHA ONLY)---Enables the compiled code to be used in combination with translated images, either because the code might call into a translated image or might be called from a translated image.
  • /[NO]UNSIGNED_CHAR---By default, char is a signed character type. The /UNSIGNED_CHAR qualifier lets you change this default to an unsigned character type, which causes all plain char declarations to have the same representation and set of values as unsigned char declarations. The default is /NOUNSIGNED_CHAR.
  • /VAXC (VAX ONLY)---Invokes the VAX C compiler. The default is set to either /DECC or /VAXC during installation.

A.1.2 Comment Processing

VAX C treats a comment in a macro definition as if the comment were replaced with no characters. This allows comments to paste tokens together, as in the following example:


#define PASTE(X) X/*  */1 
int PASTE(VAR); 

This example declares the variable VAR1 . ANSI C requires that comments be treated as if they were replaced by a single space. In Compaq C, therefore, comments cannot be used to concatenate tokens when /STANDARD=ANSI89 or /STANDARD=RELAXED_ANSI89 is specified. (The new operator ## is provided to allow token concatenation in macros.)

Compaq C for OpenVMS Systems continues to replace comments with no characters when /STANDARD=VAXC or /STANDARD=COMMON is specified; and /WARN=ENABLE=CHECK provides a diagnostic to flag comments that are used to concatenate tokens.

For /STANDARD=COMMON and /STANDARD=RELAXED_ANSI89, C++ style comments (//) are supported.

A.1.3 String Literal Concatenation

Compaq C introduces a new ANSI-compliant feature that allows convenient continuation of string literals. If string literals are separated only by white space, the string literals are concatenated to form one string literal. For example:


fputs("This is really " 
   "one string literal", stderr); 

String literal concatenation works for both normal string literals and wide string literals.

A.1.4 Recursive main() Function

In VAX C, main , or any function using the VAX C main_program option, is not recursively reentrant.

As required by ANSI C, the main function in Compaq C can now be called recursively.

A.1.5 Trigraph Sequences

ANSI C defines an additional representation of some of the special characters in the C language source abstract character set. These additional representations are sequences of three characters called trigraphs. Table A-1 lists the trigraphs and the character each is mapped to.

Table A-1 Trigraphs
Trigraph Replacement
??= #
??( [
??/ \
??) ]
??' ^
??< {
??! |
??> }
??- ~

Conceptually, every trigraph is removed from the file and its replacement is substituted. Each ? that does not begin one of the trigraphs is not changed. Trigraph processing occurs before tokenization takes place. Thus, even trigraphs in string constants have their replacements substituted.

Trigraph support has the potential to change the meaning of existing C code that unintentionally contains a trigraph in a string literal. However, since such conflicts will be quite rare, there is no facility for disabling trigraph support.

Trigraph support is available in strict and relaxed ANSI C mode.

A.1.6 Alert Escape Sequence

As specified by ANSI C, Compaq C defines a new escape sequence for the alert character. The escape sequence \a represents the ASCII BEL (Ctrl/G) character.

A.1.7 Hexadecimal Escape Sequence

VAX C limits hexadecimal escape sequences to at most 3 hex digits, but ANSI C allows an unlimited number of digits. Compaq C removes the limit imposed by VAX C.

This can cause some programs to behave differently. The string "\x0012" is currently interpreted by VAX C as a string with two characters in it: a Ctrl/A followed by the character "2". Under ANSI C rules, the string consists of a single character whose character code is hexadecimal 12 (Ctrl/R). However, this problem is unlikely to occur in practice.

A.1.8 Invalid Escape Sequences

Compaq C issues a warning message if it encounters an invalid escape sequence. VAX C did not diagnose such usage.

A.1.9 $ in Macro Names

The dollar sign ($) is not an element of the minimum basic character set allowed by the ANSI C standard. By a systemwide convention, the dollar sign identifies Compaq reserved identifiers. Compaq C for OpenVMS Systems supplies header files containing many macros with dollar signs in their names, and the VAX C compiler predefines some macros with dollar signs in their names. In strict ANSI C mode, such macros trigger a warning.

A.1.10 Null Arguments to Macros

In Compaq C, null arguments to a macro produce a BUGCHECK. VAX C allowed macro arguments to be null.

A.1.11 ANSI C Name Space Conformance

ANSI C strictly controls the name space of C programs, and prohibits compilers or their standard-specified header files from intruding on the name space reserved for user programs. Specifically, the ANSI C Standard requires that compiler extensions begin with an underscore followed by an uppercase letter or another underscore.

This affects VAX C extensions involving additional keywords and predefined macros. It also affects the freedom of Compaq C to add additional macros, variables, and functions to the standard-specified header files, such as <stdio.h> .

The following sections describe how Compaq C solves the reserved name space problem for extensions involving keywords, predefined macros, and header file contents.

A.1.11.1 Non-ANSI Keywords

VAX C has several keywords that intrude into the user name space. The Compaq C compiler in strict ANSI C mode (/STANDARD=ANSI89) does not recognize keywords that are VAX C-specific extensions to the language. They are recognized instead as identifier names. As a result, programs that use these extensions as keywords cannot be compiled in strict ANSI C mode without eliciting syntax errors.

Similarly, the Compaq C compiler in VAX C mode and relaxed ANSI C mode does recognize keywords that are VAX C-specific extensions to the language. Therefore, programs that use these names as identifiers cannot be compiled in VAX C or relaxed ANSI C mode without eliciting syntax errors. In relaxed ANSI C mode, the compiler generates a warning for these keywords. When the /STANDARD=ANSI89 qualifier is used, the compiler strictly follows the ANSI C rules about the name space, and does not recognize the old spellings as keywords.

Table A-2 shows the traditional spelling and the new spelling of the keywords affected, as well as their corresponding ANSI-compliant pragmas.

Table A-2 Non-ANSI Keywords
Keyword Corresponding ANSI-Compliant Pragma
globaldef #pragma extern_model
globalref #pragma extern_model
globalvalue #pragma extern_model
noshare #pragma extern_model
readonly #pragma extern_model

A.1.11.2 Non-ANSI Predefined Macros

Alternate spellings that follow ANSI C rules are added to Compaq C for all VAX C predefined macros. For compatibility, both the old spellings of the predefined macros and the new spellings are recognized by the compiler. However, when the /STANDARD=ANSI89 qualifier is used, the compiler strictly follows the ANSI C rules about the name space, and does not recognize the old spellings as predefined macros. You are encouraged to use the new ANSI C conformant spelling of the macros.

Table A-3 shows the traditional spelling and the new spelling of the predefined macros affected

Table A-3 New and Traditional Spellings of Macros
Traditional Spelling New Spelling
vax __ vax
vax11c __ vax11c
vaxc __ vaxc
VAX __ VAX
VAX11C __ VAX11C
VAXC __ VAXC
vms __ vms
VMS __ VMS
vms_version __ vms_version
VMS_VERSION __ VMS_VERSION

A.1.11.3 Non-ANSI Identifiers in Standard-Specified Header Files

The ANSI C standard specifies exactly what identifiers in the normal name space are declared by the standard header files. A compiler is not free to declare additional identifiers in a header file unless the identifiers follow defined rules (the identifier must begin with an underscore followed by an uppercase letter or another underscore).

When running the Compaq C compiler on OpenVMS systems in strict ANSI C mode (/STANDARD=ANSI89), versions of the standard header files are included that hide many identifiers that do not follow the rules. The <stdio.h> header file, for example, hides the definition of the macro TRUE . The compiler accomplishes this by predefining the macro __ HIDE_FORBIDDEN_NAMES in strict ANSI C mode.

You can use the command-line qualifier /UNDEFINE="__HIDE_FORBIDDEN_NAMES" to prevent the compiler from predefining this macro, thus including macro definitions of the forbidden names.

The header files are modified to only define additional VAX C names if __ HIDE_FORBIDDEN_NAMES is undefined. For example, <stdio.h> might contain the following:


#ifndef __HIDE_FORBIDDEN_NAMES 
#define TRUE    1 
#endif 

A.1.12 Compaq C Predefined Macros

Compaq C for OpenVMS Systems supports the following new system-identification macros:

__ DECC
__ alpha
__ ALPHA
__ Alpha_AXP
__ 32BITS
__ mia
__ STDC __

A.1.13 Compaq C Types

The following sections describe changes to the data types supported by Compaq C.

A.1.13.1 signed Reserved Word

Compaq C supports the new reserved word signed to complement unsigned . The signed keyword may be used with the char , short , int , and long keywords to specify the types signed char , signed short , signed int , and signed long . (These types are already supported by VAX C.) The signed keyword can also be used when declaring bit fields to specify explicitly that the bit field is signed.

ANSI C specifies that signed short , signed int , and signed long are the same types as short , int , and long , respectively. However, signed char is not the same type as char , even though Compaq C uses the same representation for both of them. This does not affect normal mixing of the two types, but it does mean that in Compaq C a pointer to signed char is not compatible with a pointer to char . Note that programs that previously used signed as an identifier will now be in error, even in VAX C mode. The /[NO]UNSIGNED_CHAR qualifier can be used to specify whether char is signed or unsigned.


Previous Next Contents Index
Buy Online or Call 1.800.888.0220      privacy statement and legal notices 
STORES CONTACT US SEARCH PRODUCTS SOLUTIONS OPTIONS DEVELOPERS