I analyze my project with cppecheck using using the compilation database (i.e. compile_commands.json file) in order to find compilation options (#defines, include path...) like this:
This worked find but got broken on March 4 2023 (and is still broken as of today 2023/07/07) since this commit:
commit7fd4118d606b64dcb1c324d37248210a27094347(HEAD)Author:OliverStöneberg<firewave@users.noreply.github.com>Date:SatMar409:02:352023+0100Fix#10039(integrate`--check-config` include findings with normal analysis) / also fixes #11283 (#3229)
Since this commit, I get a bunch of errors like this:
cppcheck cannot find any includes (std includes and projects includes). Going back to the older version of cppcheck 50eb0641b9f1b0db4321a01713fbeed4a54ed304 everything works fine.
I'm surprised this is not fixed after several months. Surely I most not be the only one using cppcheck with a compilation database compile_commands.json.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Why do you think that the missingIncludeSystem warnings are incorrect?
You should be able to suppress them if you wish.
cppcheck should be able to find all includes (system and application specific includes),
since the compilation database should give all the include paths.
As I wrote, I it reports this not only for system includes but also for includes
from my application. The same compile_command.json works fine with plenty of other tools such as clang-format, clang-tidy, clangd, include-what-you-use.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The commit that you identified merely enabled missingInclude* under more circumstances, so things were likely broken before.
Can you share any details about your compile_commands.json?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think it's reasonable for a user to assume that there won't be missing include warnings when the compile database is used.
However the include paths for <cassert> etc are not usually provided on the command line and therefore it's not provided in the compile database. The compiler looks in various system paths such as /usr/include by default. You can compile a minimal helloworld program with gcc like this:
gcc -o helloworld main.cpp
There is no need to provide the path for <iostream> on the command line.
Cppcheck does not look in /usr/include by default. And we do that by intention.
I think you should NOT provide the include path for cassert and other standard headers. I recommend that you just ignore and suppress the warnings about the standard headers.
Last edit: Daniel Marjamäki 2023-07-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. I see a regression in cppcheck introduced between those 2 commits:
I analyze my project with cppecheck using using the compilation database (i.e.
compile_commands.json
file) in order to find compilation options (#defines, include path...) like this:This worked find but got broken on March 4 2023 (and is still broken as of today 2023/07/07) since this commit:
Since this commit, I get a bunch of errors like this:
cppcheck cannot find any includes (std includes and projects includes). Going back to the older version of cppcheck
50eb0641b9f1b0db4321a01713fbeed4a54ed304
everything works fine.I'm surprised this is not fixed after several months. Surely I most not be the only one using cppcheck with a compilation database
compile_commands.json
.Why do you think that the
missingIncludeSystem
warnings are incorrect? You should be able to suppress them if you wish.CHR wrote:
cppcheck should be able to find all includes (system and application specific includes),
since the compilation database should give all the include paths.
As I wrote, I it reports this not only for system includes but also for includes
from my application. The same
compile_command.json
works fine with plenty of other tools such as clang-format, clang-tidy, clangd, include-what-you-use.The commit that you identified merely enabled
missingInclude*
under more circumstances, so things were likely broken before.Can you share any details about your
compile_commands.json
?I think it's reasonable for a user to assume that there won't be missing include warnings when the compile database is used.
However the include paths for
<cassert>
etc are not usually provided on the command line and therefore it's not provided in the compile database. The compiler looks in various system paths such as /usr/include by default. You can compile a minimal helloworld program with gcc like this:There is no need to provide the path for
<iostream>
on the command line.Cppcheck does not look in /usr/include by default. And we do that by intention.
I think you should NOT provide the include path for cassert and other standard headers. I recommend that you just ignore and suppress the warnings about the standard headers.
Last edit: Daniel Marjamäki 2023-07-08