测试代码:
//testout.c
#include <stdio.h>
void main()
{
printf("cur file : %s ; cur func : %s ; cur line : %d, gcc version: %s, base file: %s, date: %s, time: %s\n", __FILE__, __func__, __LINE__, __VERSION__, __BASE_FILE__, __DATE__, __TIME__);
return;
}
编译: gcc -o testout testout.c
运行:
./testout
cur file : testout.c ; cur func : main ; cur line : 6, gcc version: 4.5.2, base file: testout.c, date: Oct 31 2012, time: 10:42:03
//testout.c
#include <stdio.h>
void main()
{
printf("cur file : %s ; cur func : %s ; cur line : %d, gcc version: %s, base file: %s, date: %s, time: %s\n", __FILE__, __func__, __LINE__, __VERSION__, __BASE_FILE__, __DATE__, __TIME__);
return;
}
编译: gcc -o testout testout.c
运行:
./testout
cur file : testout.c ; cur func : main ; cur line : 6, gcc version: 4.5.2, base file: testout.c, date: Oct 31 2012, time: 10:42:03
一定注意是__FILE__(两个下划线而不是一个下划线_FILE_)