In addition to the ANSI-compliant, implementation-independent macros described in the DEC C Language Reference Manual, DEC C for OpenVMS Systems provides the predefined macros described in the following sections.
This macro is provided for compatibility with VAX C. The __G_FLOAT predefined macro should be used instead. See Section 6.1.4.
Each implementation of the DEC C compiler automatically defines macros that can be used 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.
Table 6-1 lists the traditional (non-ANSI) and new (ANSI) spellings of these predefined macro names for DEC C for OpenVMS Systems. Both spellings are defined for each macro unless strict ANSI C mode (/STANDARD=ANSI89) is in effect, in which case only the new spellings are defined.
Traditional Spelling | New Spelling | |
---|---|---|
Operating system name: | vms | __vms |
VMS | __VMS | |
vms_version | __vms_version | |
VMS_VERSION | __VMS_ VERSION | |
__VMS_VER | ||
__DECC_VER | ||
Architecture name: | vax (VAX only) | __vax (VAX only) |
VAX (VAX only) | __VAX (VAX only) | |
__alpha (Alpha only) | ||
__ALPHA (Alpha only) | ||
__Alpha_AXP (Alpha only) | ||
__32BITS (Alpha only) | ||
Product name: | vaxc | __vaxc |
VAXC | __VAXC | |
vax11c | __vax11c | |
VAX11C | __VAX11C | |
__DECC | ||
ANSI C version of the compiler: | __STDC__[1] | |
ISOC94 version of the compiler | __STDC_ VERSION__=199409L[2] | |
MIA version of the compiler: | __MIA[3] | |
[1] __STDC__ is defined only in strict or relaxed ANSI C mode, and MIA mode. [2] __STDC_VERSION__ is defined only when compiling with /STANDARD=ISOC94 [3] __MIA is defined only in MIA mode. |
Most of these macros are defined as 1 or 0, as appropriate to the processor and compilation qualifiers. For example, if you are compiling on an OpenVMS VAX system, the following macros are defined as if the preprocessor directives shown were included by the compiler before every compilation source group (the new spellings are shown):
#define __vax 1 #define __VAX 1 #define __vms 1 #define __VMS 1 #define __vaxc 1 #define __VAXC 1 #define __vax11c 1 #define __VAX11C 1 #define __vms_version version_number (example: V6.0) #define __VMS_VERSION version_number (example: V6.0) #define __STDC__ 1 #define __MIA 0 (1 if /STANDARD=MIA was specified.) #define __DECC 1
You can use these system identification macros to separate portable and nonportable code in any of your DEC C programs or to conditionally compile DEC C programs used on more than one operating system to take advantage of system-specific features. For example:
#ifdef VMS #include rms /* Include RMS definitions. */ #endif
See the DEC C Language Reference Manual for more information about using the preprocessor conditional-compilation directives.
The __DECC_VER macro provides an integer encoding of the compiler version-identifier string that is suitable for use in a preprocessor #if expression, such that a larger number corresponds to a more recent version.
The format of the compiler version-identifier string is:
TMM.mm-eee
Where:
The format of the integer encoding for __DECC_VER is:
vvuuteeee
Where:
Table 6-2 lists the possible version types and their encodings:
Type | Numerical Encoding | Description |
---|---|---|
T | 6 | Field-test version |
S | 8 | Customer special |
V | 9 | Officially supported version |
The following describes how the __DECC_VER integer value is calculated from the compiler version-identifier string:
The following examples show how different compiler version- identifier strings map to __DECC_VER encodings:
ident __DECC_VER string vvuuteeee T5.2-003 --> 50260003 V6.0-001 --> 60090001
The __VMS_VER macro provides an integer encoding of the OpenVMS version-identifier string that is suitable for use in a preprocessor #if expression, such that a larger number corresponds to a more recent version.
The format of the OpenVMS version-identifier string is:
TMM.mm-epp
Where:
The format of the integer encoding for __VMS_VER is:
vvuuepptt
Where:
Note that there are no version-type letters A - D and W - Z.
The following describes how the __VMS_VER integer value is calculated from the OpenVMS version-identifier string:
The suffix value is the optional edit number multiplied by 10000, added to the optional patch letter's alphabetic ordinal multiplied by 100.
The following examples show how different OpenVMS version-identifier strings map to __VMS_VER encodings:
ident __VMS_VER string vvuuepptt V6.1 --> 60100022 V6.1-1H --> 60110822 E6.2 --> 60200005 ("IFT") F6.2 --> 60200006 ("FT1") G6.2 --> 60200007 ("FT2") V6.2 --> 60200022 T6.2-1H --> 60210820 V6.2-1I --> 60210922 V5.5-1H1 --> 50510822 (extra trailing digit ignored)
The DEC C RTL contains functions whose support and syntax conform to various industry standards or levels of product or operating system support.
Table 6-3 lists macros that you can explicitly define (using the /DEFINE qualifier or the #define preprocessor directive) to control which DEC C RTL functions are declared in header files and to obtain standards conformance checking.
Macro | Standard |
---|---|
_ XOPEN_SOURCE_EXTENDED | XPG4-UNIX |
_XOPEN_SOURCE | XPG4 |
_POSIX_C_SOURCE | POSIX |
_ANSI_C_SOURCE | ISO C and ANSI C |
_VMS_V6_SOURCE | OpenVMS Version 6 compatibility |
_DECC_V4_SOURCE | DEC C Version 4.0 compatibility |
_ BSD44_CURSES | 4.4BSD Curses |
_VMS_CURSES | VAX C Curses |
_SOCKADDR_LEN | 4.4BSD sockets |
These macros, with the exception of _POSIX_C_SOURCE, can be defined to 0 or 1.
The _POSIX_C_SOURCE macro can be defined to one of the following values:
See the DEC C Run-Time Library Reference Manual for OpenVMS Systems for more information about these feature-test macros.
DEC C for OpenVMS Systems automatically defines the following macros that pertain to the format of floating-point variables. They can be used to identify the format with which you are compiling your program.
One of the first three macros listed is defined to have a value of 1 when the corresponding option of the /FLOAT qualifier is specified, or the appropriate /[NO]G_FLOAT qualifier is used. (The /G_FLOAT qualifier is kept only for compatibility with VAX C.) If the corresponding option was not specified, the associated macro is defined to have a value of 0.
On OpenVMS Alpha systems, the __X_FLOAT macro is defined to have a value of 1 when /L_DOUBLE_SIZE=128 (the default), and a value of 0 when /L_DOUBLE_SIZE=64.
These macros can assist in writing code that executes conditionally, depending on whether the program is running using D_floating, G_ floating, or IEEE_floating (Alpha only) precision.
For example, if you compiled using G_floating format, then __D_FLOAT and __IEEE_FLOAT (Alpha only) are predefined to be 0, and __G_FLOAT is predefined as if the following were included before every compilation unit:
#define __G_FLOAT 1
You can conditionally assign values to variables of type double without causing an error and without being certain of how much storage was allocated for the variable. For example, you may assign values to external variables as follows:
#ifdef __G_FLOAT double x = 0.12e308; /* Range to 10 to the 308th power */ #else double x = 0.12e38; /* Range to 10 to the 38th power */ #endif
All predefined macro names, such as __G_FLOAT, are reserved by Digital.
You can remove the effect of predefined macro definitions by explicitly undefining the conflicting name. For more information about undefining macros, see the #undefine directive in the DEC C Language Reference Manual. For more information about the G_floating representation of the double data type, see Chapter 4.
The following predefined macros are defined if the corresponding compiler mode is selected:
The following predefined macro is defined if the /POINTER_SIZE command-line qualifier is specified:
Specifying /POINTER_SIZE, /POINTER_SIZE=32, or /POINTER_SIZE=SHORT defines __INITIAL_POINTER_SIZE to 32.
Specifying /POINTER_SIZE=64, or /POINTER_SIZE=LONG defines __INITIAL_POINTER_SIZE to 64.
If /POINTER_SIZE is not specified, __INITIAL_POINTER_SIZE is defined to 0. This lets you use #ifdef __INITIAL_POINTER_SIZE to test whether or not the compiler supports 64-bit pointers, because compilers lacking pointer-size controls will not define this macro at all.
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 DEC 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 mode.
You can use the /UNDEFINE="__HIDE_FORBIDDEN_NAMES" command-line qualifier 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