United States |
Previous | Contents |
The #pragma message directive controls the issuance of individual diagnostic messages or groups of messages. Use of this pragma overrides any command-line options that may affect the issuance of messages.
This pragma has the following format:
#pragma message option1 (message-list) #pragma message option2 |
The parameter option1 must be one of the following keywords:
See the /WARNING qualifier ( Section 2.3.2.1) for a description of the message-list.
Only messages of severity Warning (W) or Information (I) can be disabled. If the message has severity of Error (E) or Fatal (F), it is issued regardless of any attempt to disable it.
The parameter option2 must be one of the following keywords:
The
save
and
restore
options are useful primarily within header files.
2.4 Using Compiler Modes and Message Control to Port your Program
The following steps describe a suggested path for porting your VAX C programs to the relaxed ANSI C mode of the Compaq C compiler.
The Compaq C compiler provides an alternative, ANSI-compliant method of controlling objects that have external linkage. To take advantage of this method, use the #pragma extern_model preprocessor directive and the /EXTERN_MODEL and /[NO]SHARE_GLOBALS command-line qualifiers.
The pragma and command-line qualifiers replace the VAX C mode storage-class specifiers ( globaldef , globalref , globalvalue ) and storage-class modifiers ( noshare and readonly ). They allow you to select the implementation model of external data and control the psect usage of your programs. The _align macro is still available to ensure object alignment.
For a description of #pragma extern_model and its relationship to the external storage classes it replaces, see the Preprocessor Directives chapter of the Compaq C User's Guide for OpenVMS Systems.
For a description of the command-line qualifiers /EXTERN_MODEL and /[NO]SHARE_GLOBALS, see the Developing C Programs at the DCL Command Level chapter of the Compaq C User's Guide for OpenVMS Systems.
For more information on external storage classes and psects, see the
Data Storage chapter of the Compaq C User's Guide for OpenVMS Systems.
2.5.1 Extern Model Defaults Have Changed
This section explains how to use /EXTERN_MODEL=COMMON_BLOCK and /SHARE_GLOBALS to obtain the same extern model defaults as VAX C.
By default, VAX C uses the common block model for external objects and treats external objects as shared (that is, the psects created for external objects are marked as shared). In the common block model, all declarations are definitions, and the linker combines all definitions with the same name into one definition.
The Compaq C default for the initial extern model is different from that of VAX C, even when compiling in VAX C mode: Compaq C uses the relaxed refdef model and treats external objects as noshare. That is, the default qualifiers that govern the initial model for external objects are /EXTERN_MODEL=RELAXED_REFDEF and /NOSHARE_GLOBALS. In the relaxed refdef model, some declarations are references and some are definitions. Multiple uninitialized definitions for the same object are allowed and resolved into one by the linker. However, a reference requires that at least one definition exists. This model is used by C compilers on UNIX systems.
Note that the change in the extern model default from share to noshare could have the following impact:
For compatibility with VAX C, you may wish to change the Compaq C default extern model. To obtain the same extern model defaults as VAX C, use the following qualifiers:
$ CC/DECC/EXTERN_MODEL=COMMON_BLOCK/SHARE_GLOBALS |
You can mix object files compiled by the VAX C compiler and the Compaq C compiler. Because Compaq C does not support parallel processing, you might want to mix object files as a workaround for parallel processing usage in your VAX C programs.
To mix object files:
$ CC/DECC PROG1 $ CC/VAXC PROG2 |
$ CC/DECC PROG1 $ CC/VAXC PROG2 $ LINK PROG1, PROG2, TT:/OPTIONS SYS$LIBRARY:VAXC2DECC.EXE/SHARE [Ctrl/Z] |
$ CC/DECC PROG1 $ CC/VAXC PROG2 $ LINK PROG1, PROG2, SYS$LIBRARY:DECCRTL.OLB/LIBRARY |
$ CC/DECC PROG1 $ CC/VAXC PROG2 $ LINK/NOSYSSHR PROG1, PROG2, SYS$LIBRARY:DECCRTL.OLB/LIBRARY/INCL=CMA$TIS |
See Section 1.2 for more information on linking with the
Compaq C RTL.
2.7 Using Predefined Macros to Aid Coexistence of VAX C and Compaq C code
This section describes how to use predefined system-identification macros to aid in the coexistence of VAX C and Compaq C code.
Each implementation of the Compaq C compiler automatically defines macros that you can use to identify the system on which the program is running. These macros can assist in writing code that executes conditionally, depending on the architecture or operating system on which the program is running, and on the compiler and/or qualifiers specified.
See the Predefined Macros and Builtin Functions chapter of the Compaq C User's Guide for OpenVMS Systems for a list of the traditional (non-ANSI) and new (ANSI) spellings of these predefined macro names for Compaq C for OpenVMS Systems.
The predefined macro symbols are defined as 1 or 0, as appropriate to the compiler, processor, and compilation qualifiers.
For the purposes of this discussion, we are interested in the __decc predefined macro. The Compaq C compiler always defines __decc to be 1; it is not defined for the VAX C compiler. You can use this fact to separate VAX C code from Compaq C code, as in the following example:
#ifdef __DECC #pragma extern_model common_block shr #endif |
In this example, if the code is being compiled by Compaq C, the default model for external variables is changed from relaxed_refdef noshr (the Compaq C default) to common_block shr (the VAX C default). See Section 2.5 for more information about #pragma extern_model .
Do not use the __vaxc predefined macro to try to distinguish between the two compilers because __vaxc is defined to be 1 both by the VAX C compiler and by the Compaq C compiler in VAX C mode.
The __alpha and __Alpha_AXP Macros
Several other predefined macros are available with Compaq C. For example, a program can use __alpha and __alpha_axp to perform processor-specific functions on Alpha systems. For example:
#ifdef __alpha void __PAL_BPT (void); #endif |
The __HIDE_FORBIDDEN_NAMES Macro
You might also find the __hide_forbidden_names macro useful.
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 for 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 header file <stdio.h> , 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 and, thereby, 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 |
For additional information on Compaq C features, see the Compaq C User's Guide for OpenVMS Systems. This guide contains a New and Changed Features appendix that you might find useful. This appendix summarizes the features that distinguish Compaq C for OpenVMS Systems from VAX C Version 3.2. You might also want to read the Common Pitfalls appendix of the user's guide.
Previous | Contents | Contents |
|