In my project, we are using both .cpp and .hpp files.
Cppcheck claims a certain function isnt used, but this is caused by Cppcheck not taking *.hpp files into account.
typically you include hpp files with #include.
my guess is you should look at the include paths.. i.e. you might need to provide some -I that tells Cppcheck where too look for headers.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
In my project, we are using both .cpp and .hpp files.
Cppcheck claims a certain function isnt used, but this is caused by Cppcheck not taking *.hpp files into account.
I have found an old 2016 answer: https://stackoverflow.com/questions/39316884/cppcheck-skips-hpp-files
But that feeld like a workaround, Is there any better solution?
My command is currently:
cppcheck.exe --error-exitcode=1 --force --enable=all --std=c++20 --suppress-xml=suppressions.xml --suppressions-list=whitelist.txt -i./<directory_to_exclude> ./</directory_to_exclude>
typically you include hpp files with #include.
my guess is you should look at the include paths.. i.e. you might need to provide some -I that tells Cppcheck where too look for headers.
If you have free-standing (i.e. not included anywhere) header files you need to specify them explicitly.
If you could provide a reduced samples showing the issue that might also help.