2

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?

1 Answer 1

4

It seems that one can not change the extension cppcheck is looking for when scanning a directory. There are some other options:

  1. Have a text file with a list of all your *.hpp files and run cppcheck with the --file-list=<file> parameter.

  2. Run cppcheck for every *.hpp file directly, giving the filename on command line.

  3. Create *.cpp files that include the include those *.hpp files so that cppcheck can find them. Those could be tests for your library.

Sign up to request clarification or add additional context in comments.

3 Comments

I am a Cppcheck developer. I agree with this answer. I recommend option 3.
@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?
@DanielMarjamäki Any thoughts on my question in the previous comment?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.