VMS Help
CC, Language topics, Predefined Macros
*Conan The Librarian (sorry for the slow response - running on an old VAX)
|
|
In addition to the ANSI-compliant, implementation-independent
macros described in the Compaq C Language Reference Manual, Compaq
C for OpenVMS systems provides the following predefined macros:
1 - System Identification Macros
|
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.
The following table lists the traditional and new spellings of
these predefined macro names for Compaq C on OpenVMS systems. Both
spellings are defined for each macro unless ANSI C mode is in
effect (/STANDARD=ANSI89), in which case only the new spellings are
defined.
Traditional spelling New spelling
vms __vms
VMS __VMS
vms_version __vms_VERSION
VMS_VERSION __VMS_VERSION
__VMS_VER
__DECC_VER
__DECCXX_VER
vax __vax
VAX __VAX
vaxc __vaxc
VAXC __VAXC
vax11c __vax11C
VAX11C __VAX11C
--- __DECC
--- __STDC__
__STDC_HOSTED__
__STDC_VERSION__
__STDC_ISO_10646__
__MIA
Note that __STDC__ is defined only in strict ANSI C mode.
Predefined macros (with the exception of vms_version, VMS_VERSION,
__vms_version and __VMS_VERSION) are defined as 1 or 0, depending
on the system you're compiling on (VAX or Alpha processor), the
compiler defaults, and the qualifiers used. For example, if you
compiled using G_floating format, then __D_FLOAT and __IEEE_FLOAT
(Alpha processors 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
These macros can assist in writing code that executes
conditionally. They can be used in #elif, #if, #ifdef, and #ifndef
directives to separate portable and nonportable code in a Compaq C
program. The vms_version, VMS_VERSION, __vms_version, and
__VMS_VERSION macros are defined with the value of the OpenVMS
version on which you are running (for example, Version 6.0).
The following predefined macros are defined as 1 if the
corresponding compiler mode is selected (Otherwise, they are
undefined):
__DECC_MODE_STRICT ! /STANDARD=ANSI89
__DECC_MODE_RELAXED ! /STANDARD=RELAXED_ANSI89
__DECC_MODE_VAXC ! /STANDARD=VAXC
__DECC_MODE_COMMON ! /STANDARD=COMMON
__STDC__ ! /STANDARD=ANSI89, /STANDARD=RELAXED_ANSI89
__STDC_VERSION__ ! /STANDARD=ISOC94
__MS ! /STANDARD=MS
3 - Floating Point Macros
|
Compaq C automatically defines the following predefined macros
pertaining to the format of floating-point variables. You can use
them to identify the format with which you are compiling your
program:
__D_FLOAT
__G_FLOAT
Compaq C defines the following macros that you can explicitly
define (using the /DEFINE qualifier or the #define preprocessor
directive) to control which Compaq C RTL functions are declared in
header files and to obtain standards conformance checking:
_XOPEN_SOURCE_EXTENDED
_XOPEN_SOURCE
_POSIX_C_SOURCE
_ANSI_C_SOURCE
_VMS_V6_SOURCE
_DECC_V4_SOURCE
__BSD44_CURSES
__VMS_CURSES
_SOCKADDR_LEN
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 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 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
When you compile using the /G_FLOAT qualifier, CC$gfloat is defined
as 1. When you compile without the /G_FLOAT qualifier, CC$gfloat
is defined as 0. The CC$gfloat macro is provided for compatiblity
with VAX C. The __G_FLOAT predefined macro should be used instead.
The __DATE__ macro evaluates to a string specifying the date on
which the compilation started. The string presents the date in the
form "Mmm dd yyyy" The names of the months are those generated by
the asctime library function. The first d is a space if dd is less
than 10.
Example:
printf("%s",__DATE__);
The __FILE__ macro evaluates to a string literal specifying the
file specification of the current source file.
Example:
printf("file %s", __FILE__);
The __LINE__ macro evaluates to a decimal constant specifying the
number of the line in the source file containing the macro
reference.
Example:
printf("At line %d in file %s", __LINE__, __FILE__);
The __TIME__ macro evaluates to a string specifying the time that
the compilation started. The time has the following format:
hh:mm:ss
Example:
printf("%s", __TIME__);
The value of this macro remains constant throughout the translation
unit.
[legal]
[privacy]
[GNU]
[policy]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.