I try to use the CPPChek GUI to do a static analysis of my code code.
I use CMake to generate compile database file (compile_commands.json).
And when I create a project importing this file, no error are show on my code (even if I do a specific mistake) except for the missing include system.
And when I do a directories analyze, I see all the errors.
(Same when I used the command line)
When I check the checkers, I have nothing enable when I used the project (see the attachment).
Yes, I have an error (preprocessorErrorDirective) and yes, I use GCC to compile.
This error is in a header file in library folder I use. It automatically define some macro depending the compiler.
With the GUI, I'm not able to modify the project setting (path, include, ...) when importing a compile database.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
that preprocessorErrorDirective must be fixed. Otherwise all the checkers will be skipped.
With the GUI, I'm not able to modify the project setting (path, include, ...) when importing a compile database.
If you use latest Cppcheck then you can configure extra defines. I would assume that you can fix the preprocessorErrorDirective with an extra define. Can you show the ifdef(s) before the #error ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I thought it was enabled in 2.14.1 but it seems not. I will probably tag 2.14.2 in near future I will put the change in that.
A workaround that I think should work in 2.14.0 is;
1. clear the compile_commands.json so the paths and defines are enabled
2. write __GNUC__ in the defines textbox
3. readd the compile_commands.json
Last edit: Daniel Marjamäki 2024-06-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
does it happen in command line also? use --project=yourproject.cppcheck to import the GUI project file.
it would be interesting if you could pinpoint the crash and imho the best way is if you compile and run cppcheck in debug mode. The command-line tool is pretty straight forward to compile imho. The GUI is not difficult to build but you need a Qt SDK not just a C++ compiler.
Last edit: Daniel Marjamäki 2024-06-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dear,
I try to use the CPPChek GUI to do a static analysis of my code code.
I use CMake to generate compile database file (compile_commands.json).
And when I create a project importing this file, no error are show on my code (even if I do a specific mistake) except for the missing include system.
And when I do a directories analyze, I see all the errors.
(Same when I used the command line)
When I check the checkers, I have nothing enable when I used the project (see the attachment).
How can I enable checkers with a project ?
I have that behaviour if I don't set
-D__GNUC__=9
, but I don't understand why.Do you have critical errors? The checkers report should show if you have critical errors at the top.
--checkers-report=report.txt
In the GUI you can see the checkers report in the statistics window.
No, I don't get critical errors.
The only checkers that stay on are:
nofile:0:0: information: Active checkers: 10/1002
Last edit: Dzid 2024-06-06
It seems that you have critical errors when you use the compile database.
Sorry for this late reply.
Yes, I have an error (preprocessorErrorDirective) and yes, I use GCC to compile.
This error is in a header file in library folder I use. It automatically define some macro depending the compiler.
With the GUI, I'm not able to modify the project setting (path, include, ...) when importing a compile database.
that preprocessorErrorDirective must be fixed. Otherwise all the checkers will be skipped.
If you use latest Cppcheck then you can configure extra defines. I would assume that you can fix the preprocessorErrorDirective with an extra define. Can you show the ifdef(s) before the #error ?
I use the latest version (2v.14.0)
yeah, the error directive is because there is no compiler defined (GCC in my case)
and all is disable when I try to edit the project
I thought it was enabled in 2.14.1 but it seems not. I will probably tag 2.14.2 in near future I will put the change in that.
A workaround that I think should work in 2.14.0 is;
1. clear the
compile_commands.json
so the paths and defines are enabled2. write
__GNUC__
in the defines textbox3. readd the
compile_commands.json
Last edit: Daniel Marjamäki 2024-06-13
OK, it seems to work by setting the extra define before the database file
I don't see the error during the analyze
But cppcheck crashs just before the end of the analyze (at 99%)
does it happen in command line also? use
--project=yourproject.cppcheck
to import the GUI project file.it would be interesting if you could pinpoint the crash and imho the best way is if you compile and run cppcheck in debug mode. The command-line tool is pretty straight forward to compile imho. The GUI is not difficult to build but you need a Qt SDK not just a C++ compiler.
Last edit: Daniel Marjamäki 2024-06-13
It craches on CLI too.
I will try to do it in debug mode.