三个宏__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 

 

相关文章:

  • 2022-02-20
  • 2022-01-07
  • 2022-01-07
  • 2021-11-01
  • 2021-11-28
猜你喜欢
  • 2022-12-23
  • 2021-09-08
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
相关资源
相似解决方案