Some predefined Macros in the c Standard
From: http://www.wangchao.net.cn/bbsdetail_149674.html
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.
Macro
Meaning
_ Date __
Date of preprocessing (string text in the form of "Mmm dd YYYY)
_ File __
Represents the current Source code String Text of the file name
_ Line __
Indicates the Current Source Code Integer constant of the row number in
_ Time __
Source File Compilation Time, in the format of "HH: mm: SS"
_ FUNC __
Current function name
For macros such as _ file __,__ line __,__ func _, Program It is very useful, 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 __);
}