CC预先定义的宏: __FILE__, __func__, __LINE__, etc

来源:互联网 发布:湖北大学知行学院官网 编辑:程序博客网 时间:2024/06/07 01:42

http://fanrey.iteye.com/blog/1709353

博客分类: 
  • C/C++

  • 测试代码: 
    //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_)
    0 0