Removing -I helps for this simplified case. I saw this issue while trying to run cppcheck on larger projects like xfce4-places-plugin.
For those projects, I run cppcheck --enable=all --library=gtk --project=builddir/compile_commands.json. The -I directories seem to get picked up automatically from the JSON data:
I thought that including gtk.cfg would solve the g_assert false positives, but it ends up introducing the syntaxError on top of the nullPointerRedundantCheck errors.
It seems like my approach of using --project and --library=gtk is not recommended?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hm, I still see the syntaxError with -isystem. I also tried -i/usr/ and -igtkenums.h and got the same error. I guess the /usr/include/gtk-3.0/gtk/gtkenums.h header gets checked indirectly?
I investigated the false positives with g_assert and found that a GLib header (glib/gtestutils.h) has a g_assert definition that seems to take precedence over the definition from the gtk.cfg file. Is there any way to make the library definition take precedence?
During my testing, I accidentally created an invalid JSON file (with an extra trailing comma) and crashed cppcheck:
Hi,
I am seeing a false positive syntaxError when I run
cppcheck -I /usr/include/gtk-3.0/ --library=gtkon this simplified code:Output:
Here is the relevant code from
gtkenums.h:And here is the relevant definition from
gtk.cfg:Is this a known issue? Thanks!
Version info:
Using
--libraryand giving cppcheck access to the corresponding headers is not recommended, what happens if you remove-I?Removing
-Ihelps for this simplified case. I saw this issue while trying to run cppcheck on larger projects like xfce4-places-plugin.For those projects, I run
cppcheck --enable=all --library=gtk --project=builddir/compile_commands.json. The-Idirectories seem to get picked up automatically from the JSON data:I added
--library=gtkbecause I was seeing false positives withg_assertwhen runningcppcheck --enable=all --project=builddir/compile_commands.json:I thought that including gtk.cfg would solve the
g_assertfalse positives, but it ends up introducing the syntaxError on top of the nullPointerRedundantCheck errors.It seems like my approach of using
--projectand--library=gtkis not recommended?I see. Maybe
-isystemwould help?Hm, I still see the syntaxError with
-isystem. I also tried-i/usr/and-igtkenums.hand got the same error. I guess the/usr/include/gtk-3.0/gtk/gtkenums.hheader gets checked indirectly?I investigated the false positives with
g_assertand found that a GLib header (glib/gtestutils.h) has ag_assertdefinition that seems to take precedence over the definition from thegtk.cfgfile. Is there any way to make the library definition take precedence?During my testing, I accidentally created an invalid JSON file (with an extra trailing comma) and crashed cppcheck: