ANSI/ISO Standard Predefined Macros

The ILE C/C++ compiler recognizes the following macros defined by the ANSI/ISO Standard. Unless otherwise specified, macros when defined have a value of 1.
A character string literal containing the date when the source file was compiled. The date is in the form:
   "Mmm dd yyyy"
  • 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.
  • yyyy represents the year.
Defined as a character string literal containing the name of the source file.
Defined to be an integer representing the current source line number.
C compiler only Defined if the C compiler conforms to the ANSI standard. This macro is defined if the language level is set to LANGLVL(*ANSI).
C compiler only Defined to be an integer constant of type long int. This macro is defined only if __STDC__ is also defined and has the value 199409L. This macro is not defined for C++.
Defined as a character string literal containing the time when the source file was compiled. The time is in the form:
  • hh represents the hour.
  • mm represents the minutes.
  • ss represents the seconds.
C++ compiler only Defined when compiling a C++ program, indicating that the compiler is a C++ compiler. This macro has no trailing underscores. This macro is not defined for C.
  1. Predefined macro names cannot be the subject of a #define or #undef preprocessor directive.
  2. The predefined ANSI/ISO Standard macro names consist of two underscore (__) characters immediately preceding the name, the name in uppercase letters, and two underscore characters immediately following the name.
  3. The value of __LINE__ changes during compilation as the compiler processes subsequent lines of your source program.
  4. The value of __FILE__ and __TIME__ changes as the compiler processes any #include files that are part of your source program.
  5. C compiler only You can also change __LINE__ and __FILE__ using the #line preprocessor directive.


The following printf() statements display the values of the predefined macros __LINE__, __FILE__, __TIME__, and __DATE__ and print a message indicating if the program conforms to ANSI standards based on __STDC__:
#include <stdio.h>
#ifdef __STDC__
#   define CONFORM    "conforms"
#   define CONFORM    "does not conform"
int main(void)
  printf("Line %d of file %s has been executed\n", __LINE__, __FILE__);
  printf("This file was compiled at %s on %s\n", __TIME__, __DATE__);
  printf("This program %s to ANSI standards\n", CONFORM);

Related Information

See the ILE C/C++ Language Reference for additional information on predefined macros.