How to list all included header files using a c file (preferably in Vim)

Is there a way to see all the header files included in the c file.

Suppose file c contains only one header file, but this header file
includes 10 header files, and those 10 include even more and so on ...

I want to get a list of all the header files that will eventually be included

+4
source share
4 answers

But the real team for this is

:checkpath 

It will list the missing headers. To view all headers (in the link tree)

 :checkpath! 

You need to know the meaning of the settings 'include' , 'isfname' and 'path' , in the context of which you can enable validation. Obviously, the defaults will work fine for C / C ++ sources. Many file type plugins will have corresponding definitions for working with other file types.

+4
source

A common technique is to use cpp:

  $ cpp -M file.c
+3
source

You can use -E -H with CC. Similar options should exist for gcc.

0
source

I found that a useful CL switch is this switch:

 /ShowIncludes 

This causes the CL to print a few indentation on stdout, as shown below. It can provide you with a hierarchy from which they are included:

 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 
0
source

Source: https://habr.com/ru/post/1346308/


All Articles