Header file inclusion static analysis tools?

后端 未结 8 518
旧时难觅i
旧时难觅i 2020-12-02 17:42

A colleague recently revealed to me that a single source file of ours includes over 3,400 headers during compile time. We have over 1,000 translation units that get compiled

相关标签:
8条回答
  • 2020-12-02 18:03

    I heard there are some tools do it, but I don't use them.

    I created some tool https://sourceforge.net/p/headerfinder may be this is useful. Unfortunately it is "HOME MADE" tool with following issues,

    • Developed in Vb.Net
    • Source code need to compiled
    • Very slow and consumes memory.
    • No help available.
    0 讨论(0)
  • 2020-12-02 18:05

    a few things-

    • use "preprocess only" to look at your preprocessor output. gcc -E option, other compilers have the function too

    • use precompiled headers.

    • gcc has -verbose and --trace options which also display the full include tree, MSVC has the /showIncludes option found under Advanced C++ property page

    Also, Displaying the #include hierarchy for a C++ file in Visual Studio

    0 讨论(0)
提交回复
热议问题