Predefined Identifier and Macros Example

1
2
3
4
5
6
7
8
9
10
11
12
#include <stdio.h>
 
void main() {
    // The compiler supports this predefined identifier specified by ISO C99 and C++11.
    printf("__FUNCTION__\t: %s\n", __FUNCTION__);
 
    // The compiler supports these predefined macros specified by the ISO C99 and C++14 standards.
    printf("__DATE__\t: %s\n", __DATE__);
    printf("__TIME__\t: %s\n", __TIME__);
    printf("__FILE__\t: %s\n", __FILE__);
    printf("__LINE__\t: %d\n", __LINE__);
}
1
2
3
4
5
__FUNCTION__    : main
__DATE__        : Aug 30 2017
__TIME__        : 21:01:11
__FILE__        : main.cpp
__LINE__        : 11


References