Menu

Optimizing Include files...

2020-12-31
2021-01-29
  • David V. Corbin

    David V. Corbin - 2020-12-31

    Was hoping CppCheck could help...

    1) Missing - there is an active #include for the configuration, but the header can not be found (what header file name, what file path is it involved in)
    2) Unnecessary - None of the content in the header file (nor what it includes) has a material impact on the compilation
    3) Unused - None of the solutions in a system include the header, though it exists on one of the include paths
    4) Extraneous include paths - No actual relevant .h files were loaded from this path.

    There are a few advanced variants, but this should give an idea...

    I am asking because I have been charged with modernizing a 25 year old (continual development, but no preventative maintenance) that has over 5000 separate .vcxproj (Visual Studio) across over 1000 solutions, with 17.5K++ .cpp files and 25K++ .h files... Manual examination is NOT going to be feasible...

     
  • Daniel Marjamäki

    I fear that is beyond the scope of cppcheck. I made a tool ~10 years ago https://github.com/danmar/checkheaders feel free to try it out. I made it a separate tool because it required a different preprocessing and/or lexing. It was not possible 10 years ago to use Cppcheck infrastructure directly. I do not remember the details maybe it would work better today.
    But I'd guess more modern tools might be better. I have not tested it but the "include what you use" iwyu might do what you want.

     
  • Oliver Stöneberg

    You might want to take a look at https://include-what-you-use.org/ - beware distros have quite outdated versions of it and it has false positives. It requires a compilation database though.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.