#line使用分析

来源:互联网 发布:软件项目进度报告 编辑:程序博客网 时间:2024/06/03 16:58

1 #line的用法

  • #line用于强制指定新的行号和编译文件名,并对源程序的代码重新编号。
    • 用法:#line number filename (filename可省略)。
  • #line编译指示字的本质是重定义 __LINE__ 和 __FILE__(由此可以看出来是由预处理进行处理的)。

编程实验:#line的使用

#include <stdio.h>// The code section is written by A.// Begin#line 1 "a.c"// End// The code section is written by B.// Begin#line 1 "b.c"// End// The code section is written by Delphi.// Begin#line 1 "delphi_tang.c"int main(){    printf("%s : %d\n", __FILE__, __LINE__);    printf("%s : %d\n", __FILE__, __LINE__);    return 0;}// End

2 小结

  • #line用于强制指定新的行号和编译文件名。
原创粉丝点击