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 _ represents the string Text of the current source code file name
_ Line _ represents the integer constant of the row number in the current source code.
_ Time _ source file Compilation Time in the format of "HH: mm: SS"
_ FUNC _ the current function name // added to c99, which is not supported by some Compilers
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.", _ file __);
Printf ("the date is % S.", _ date __);
Printf ("the time is % S.", _ time __);
Printf ("this is line % d.", _ line __);
Printf ("this function is % S.", _ FUNC __);
Why_me ();
Return 0;
}
Void why_me ()
{
Printf ("this function is % s", _ FUNC __);
Printf ("the file is % S.", _ file __);
Printf ("this is line % d.", _ line __);
}