有没有办法查看c文件包含的所有头文件。
假设一个c文件只包含一个头文件,但该头文件为 包括10个头文件,其中10个包括更多等等......
我想获得最终包含的所有头文件的列表
答案 0 :(得分:4)
但真正的命令是
:checkpath
它会列出缺少的标题。要查看所有标题(在参考树中)
:checkpath!
您需要在此包含检查的上下文中了解'include'
,'isfname'
和'path'
设置的含义。显然,默认值适用于C / C ++源代码。许多文件类型插件都带有适当的定义,可以与其他类型的文件一起使用。
答案 1 :(得分:3)
一种常见的技术是使用cpp:
$ cpp -M file.c
答案 2 :(得分:0)
您可以在CC中使用-E -H。 gcc应该存在类似的选项。
答案 3 :(得分:0)
我发现这个开关是一个有用的CL开关:
/ShowIncludes
它导致CL输出到 stdout 一个稍微缩进的列表,如下所示。它可以为您提供包含它们的头文件的层次结构:
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\windows.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\sdkddkver.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\excpt.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\crtdefs.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\sal.h
Note: including file: c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\vadefs.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\stdarg.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\windef.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\winnt.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\ctype.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\crtdefs.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\specstrings.h
Note: including file: c:\program files\microsoft sdks\windows\v7.1\include\sal_supp.h
Note: including file: c:\program files\microsoft sdks\windows\v7.1\include\specstrings_supp.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\specstrings_strict.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\specstrings_undef.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\driverspecs.h
Note: including file: c:\program files\microsoft sdks\windows\v7.1\include\sdv_driverspecs.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\kernelspecs.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\basetsd.h
Note: including file: C:\Program Files\Microsoft SDKs\Windows\v7.1\INCLUDE\guiddef.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\string.h
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\crtdefs.h
... and the list continues