Some predefined macros are specified in the c standard and are often used in programming. The following table lists some predefined macros that are frequently used.
_ DATE __
Date of preprocessing (string text in the form of "Mmm dd yyyy)
_ FILE __
String text representing the current source code file name
_ LINE __
An integer constant representing the row number in the current source code.
_ TIME __
Source File Compilation Time, in the format of "hh: mm: ss"
_ Func __
Current function name
It is useful for macros such as _ FILE __,__ LINE __,__ func _ in program debugging, because you can easily know the row of the file to which the program runs and the function.
The following example prints the predefined macros.
# Include <stdio. h>
# Include <stdlib. h>
Void why_me ();
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 ("The file is % s. \ n", _ FILE __);
Printf ("This is line % d. \ n", _ LINE __);
}
/* Note that I tested the above Code on the C/C ++ compiler and found that _ func _ is not defined under VC6.0 */
Author: lifeiaidajia