日期:2014-05-16  浏览次数:20631 次

Linux几个调试宏__FUNCTION__ __TIME__ __LINE__ __FILE__ __DATA__

这几个宏是编译器内置的,不是在哪个头文件中包含的
直接上最简单的例子就好了,没必要多说。

源码:

#include <stdio.h>

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", __FUNCTION__ );	
	
    return 0;
}

运行结果:

The file is macro.c.
The date is Aug 24 2012.
The time is 23:13:26.
This is line 8.
This function is main.