I have a heavily templated project that is using the system of having a .h file with the function declarations #include a corresponding .hpp with the function definitions. However, cppcheck doesn't seem to parse the .hpp files, and I don't see an option to change the file extensions that it parses. How do people usually handle this?
Add a comment |
1 Answer
It seems that one can not change the extension cppcheck is looking for when scanning a directory. There are some other options:
Have a text file with a list of all your
*.hppfiles and run cppcheck with the--file-list=<file>parameter.Run cppcheck for every
*.hppfile directly, giving the filename on command line.Create
*.cppfiles that include the include those*.hppfiles so that cppcheck can find them. Those could be tests for your library.
3 Comments
Daniel Marjamäki
I am a Cppcheck developer. I agree with this answer. I recommend option 3.
David Doria
@michalsrb For Option 3, do I need to actually build those .cpp files (or "that file" if I can just use one for all of the .hpp references?) with the project (i.e. do they need a main(), etc.)? Or do I just literally have a giant list of
#include "Class1.hpp" #include "Class2.hpp" in a file called something like "HppForCppcheck.cpp" that doesn't actually get referenced by the project anywhere?David Doria
@DanielMarjamäki Any thoughts on my question in the previous comment?