三个宏__FILE__  __FUNCTION__  __LINE__

__是两个下划线

__FILE__这个宏是定位哪个文件;

__FUNCTION__这个宏定位哪个函数;

__LINE__这个宏定位哪一行;

例程:

#include<stdio.h>

void test_0(void);
void test_1(void);

int main(void)
{
    printf("hello Kun \n");
    printf("%s; %s; %d \n",__FILE__,__FUNCTION__,__LINE__);

    test_1();

    return 0;
}

void test_0(void)
{
    printf("%s; %s; %d \n",__FILE__,__FUNCTION__,__LINE__);
}

void test_1(void)
{
    printf("%s; %s; %d \n",__FILE__,__FUNCTION__,__LINE__);
    test_0();
}

运行结果:
hello Kun 
test.c; main; 9 
test.c; test_1; 23 
test.c; test_0; 18 

 

posted on 2013-11-01 09:55  深蓝工作室  阅读(162)  评论(0编辑  收藏  举报