The C standard predefined macros - C Reference

C examples for Reference:Language Reference

Introduction

Macro Meaning
__DATE__ A character string literal in the form "Mmm dd yyyy" representing the date of preprocessing, as in Nov 23 2013
__FILE__ A character string literal representing the name of the current source code file
__LINE__ An integer constant representing the line number in the current source code file
__STDC__ Set to 1 to indicate the implementation conforms to the C Standard
__TIME__ The time of translation in the form "hh:mm:ss"
__func__ expands to a string representing the name of the function containing the identifier

Demo Code

#include <stdio.h>
void why_me();/*from   w ww  . j  ava2 s  .c  o m*/

int main()
{
    printf("The file is %s.\n", __FILE__);
    printf("The date is %s.\n", __DATE__);
    printf("The time is %s.\n", __TIME__);
    printf("This is line %d.\n", __LINE__);
    printf("This function is %s\n", __func__);
    why_me();
    
    return 0;
}

void why_me()
{
    printf("This function is %s\n", __func__);
    printf("This is line %d.\n", __LINE__);
}

Result


Related Tutorials