General macros

The following predefined macros are always predefined by the compiler. Unless noted otherwise, all the following macros are protected, which means that the compiler will issue a warning if you try to undefine or redefine them.

Table 1. General predefined macros
Predefined macro name Description Predefined value
__COUNTER__ Expands to an integer that starts from 0. The value increases by 1 each time this macro is expanded.

You can use this macro with the ## operator to generate unique variable or function names. The following example shows the declaration of distinct identifiers with a single token:

#define CONCAT(a, b) a##b
#define CONCAT_VAR(a, b) CONCAT(a, b)
#define VAR CONCAT_VAR(var, __COUNTER__)

//Equivalent to int var0 = 1;
int VAR = 1; 

//Equivalent to char var1 = 'a'; 
char VAR = 'a'; 
An integer variable that starts from 0. The value increases by 1 each time this macro is expanded.
__FUNCTION__ Indicates the name of the function currently being compiled. A character string containing the name of the function currently being compiled.
__LIBREL__ Indicates the Language Environment® library level under which the compiler is running. The return value of a compiler call to the librel library function.
__ptr31__ Expands to the pointer qualifier __ptr32. Not protected. __ptr32
__PTR32 Indicates that the pointer qualifier __ptr32 is recognized. Not protected. 1
__TARGET_LIB__ Indicates the version of the target library. A hexadecimal string literal representing the version number of the target library. The format of the version number is hex PVRRMMMM, where:
P
Represents the z/OS® XL C or C/C++ library product. The possible values are:
  • 2 for OS/390®
  • 4 for z/OS Release 2 and later
V
Represents the version number
RR
Represents the release number
MMMM
Represents the modification number
The value of the __TARGET_LIB__ macro depends on the setting of the TARGET compiler option, which allows you to specify the runtime environment and release for the generated object module. The __TARGET_LIB__ macro is set as follows:
  • Start of change0x42040000 (for zOSV2R4 TARGET suboption)End of change
  • 0x42030000 (for zOSV2R3 TARGET suboption)
  • 0x42020000 (for zOSV2R2 TARGET suboption)
If the TARGET suboption is specified as a hexadecimal string literal, this macro is also defined to that literal.
__TIMESTAMP__ Indicates the date and time when the source file was last modified. The value changes as the compiler processes any include files that are part of your source program.

This macro is available for partitioned data sets (PDSs/PDSEs) and z/OS UNIX files only. For PDSE or PDS members, the ISPF timestamp for the member is used if present. For PDSE/PDS members with no ISPF timestamp, sequential data sets, or in stream source in JCL, the compiler returns a dummy timestamp. For z/OS UNIX files, the compiler uses the system timestamp on a source file. Otherwise, it returns a dummy timestamp, "Mon Jan 1 0:00:01 1990".

A character string literal in the form "Day Mmm dd hh:mm:ss yyyy", where:
Day
Represents the day of the week (Mon, Tue, Wed, Thu, Fri, Sat, or Sun).
Mmm
Represents the month in an abbreviated form (Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec).
dd
Represents the day. If the day is less than 10, the first d is a blank character.
hh
Represents the hour.
mm
Represents the minutes.
ss
Represents the seconds.
yyyy
Represents the year.