小智 7
如果您只是在文件上运行cpp(C预处理器),则输出将包含表单的#line指令
#line 45 "silly-file-with-macros.h"
Run Code Online (Sandbox Code Playgroud)
为编译器说明一切都来自哪里.所以一种方法是使用
cpp my-file.c | more
Run Code Online (Sandbox Code Playgroud)
并寻找#line指令.
根据您的编译器,您可以使用的另一个技巧是将宏重新定义为其他内容,编译器将发出类似的警告
test-eof.c:5:1: warning: "FRED" redefined
test-eof.c:3:1: warning: this is the location of the previous definition
Run Code Online (Sandbox Code Playgroud)
(这是来自gcc),它应该告诉你之前定义宏的位置.但是想一想,你怎么没有得到那个警告呢?
另一个想法是使用makedepend获取所有包含文件的列表,然后grep它们中的#define行.
| 归档时间: |
|
| 查看次数: |
200 次 |
| 最近记录: |