收集自网络:
__FILE__:当前源代码文件名的字符串文字
__LINE__:当前源代码中的行号的整数常量
__DATE__:进行预处理的日期(“Mmm dd yyyy”形式的字符串文字)
__TIME__:源文件编译时间,格式微“hh:mm:ss”
__func__:当前所在函数名,在C++中为__FUNCTION__
C++的测试代码如下(g++),其中VC中不支持__func__ :
#include using namespace std; #ifndef __func__ #define __func__ (__FUNCTION__) #endif void func() { cout<<"func name is:"<<__func__<<endl; cout<<"func name is:"<<__FUNCTION__<<endl; } int main() { cout<<"date is :"<<__DATE__<<endl; cout<<"time is :"<<__TIME__<<endl; cout<<"file is :"<<__FILE__<<endl; cout<<"line is :"<<__LINE__<<endl; func(); }