HELPLIB.HLB  —  CC  Language topics, Predefined Macros
  In addition to the ANSI-compliant, implementation-independent
  macros described in the HP C Language Reference Manual, The VSI C
  compiler provides the following predefined macros:

1  –  System Identification Macros

  Each implementation of the VSI 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 VSI 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
             vaxc                  __vaxc
             VAXC                  __VAXC
             vax11c                __vax11C
             VAX11C                __VAX11C
              ---                  __DECC
              ---                  __STDC__
                                   __STDC_HOSTED__
                                   __STDC_VERSION__
                                   __STDC_ISO_10646__
                                   __MIA

  On OpenVMS I64 Systems, VSI C also supports the following
  predefined system identification macro names in all compiler modes:

  __ia64
  __ia64__
  __32BITS
  __INITIAL_POINTER_SIZE

  Predefined macros (with the exception of __STDC_VERSION__,
  __STDC_ISO_10646__, vms_version, VMS_VERSION, __vms_version,
  __VMS_VERSION, and __INITIAL_POINTER_SIZE) 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 VSI 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 __STDC__ macro is defined to 1 for /STANDARD options ANSI89,
  C99, LATEST and MIA.  It is defined to 2 for /STANDARD=RELAXED and
  to 0 for /STANDARD=MS.  It is not defined for /STANDARD options
  VAXC and COMMON.

  The __STDC_HOSTED__ macro is defined to 1 for /STANDARD=c99 and
  /STANDARD=LATEST.  It is not defined for all other /STANDARD
  keywords.

  The __STDC_VERSION__ macro is defined to 199901L for /STANDARD
  keywords C99, LATEST, RELAXED, MS, PORTABLE.  It is defined to
  199409L when the ISOC94 keyword is specified alone or with the
  ANSI89, MIA, RELAXED, MS, PORTABLE, or COMMON modes.  The macro is
  undefined for the VAXC keyword or for keywords ANSI89, MIA, or
  COMMON without ISOC94 specified.

  The __STDC_ISO_10646__ macro evaluates to an integer constant of
  the form yyyymmL (for example, 199712L), intended to indicate that
  values of type wchar_t are the coded representations of the
  characters defined by ISO/IEC 10646, along with all amendments and
  technical corrigenda as of the specified year and month.

2  –  Compiler Mode Macros

  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
  __DECC_MODE_VAXC       !  /STANDARD=VAXC
  __DECC_MODE_COMMON     !  /STANDARD=COMMON
  __STDC__               !  /STANDARD=ANSI89, /STANDARD=RELAXED
  __STDC_VERSION__       !  /STANDARD=ISOC94
  __MS                   !  /STANDARD=MS

3  –  Floating Point Macros

  VSI 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
  __IEEE_FLOAT
  _IEEE_FP
  __X_FLOAT

4  –  RTL Standards Macros

  VSI C defines the following macros that you can explicitly define
  (using the /DEFINE qualifier or the #define preprocessor directive)
  to control which VSI 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

5  –  HIDE FORBIDDEN NAMES

  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 you compile with VSI C using any values of /STANDARD that set
  strict C standard conformance (ANSI89, MIA, C99, and LATEST),
  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 for the above-mentioned /STANDARD values.

  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

6  –  CC$gfloat

  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.

7  –  DATE

  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__);

8  –  FILE

  The __FILE__ macro evaluates to a string literal specifying the
  file specification of the current source file.

  Example:

       printf("file %s", __FILE__);

9  –  LINE

  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__);

10  –  TIME

  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.
Close Help