The following are preprocessor variables and part of the C/C++ standard. During preprocessing, they are replaced respectively by a constant string or a integer .
- '__DATE__' -> a string literal of the form "Mmm dd yyyy"
- '__TIME__' -> a string literal of the form "hh:mm:ss"
- '__TIMESTAMP__' -> a string literal of the form "Mmm dd yyyy hh:mm:ss"
- '__FUNCTION__' -> a string literal which contains the function name (this is part of C99, the new C standard and not all C++ compilers support it)
- '__FILE__' -> a string literal holding the current file name
- '__LINE__' -> a integer representing the current line number.
在程序中可以直接使用這些宏。
例如:
printf("Filename:%10s Line: %s ",__FILE__,__LINE__);