-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cppcheck throws error - warning: There is an unknown macro here somewhere G_DEFINE_TYPE #1196
Comments
|
Maybe cppcheck 2.9 needs gtk to be specified with |
Recent versions of cppcheck (2.9+) seem to require this configuration. The gtk.cfg configuration file is part of cppcheck itself. Closes geany#1196.
|
Good guess! It was as easy as this. Thanks. Now, cppcheck finds new issues. The library flag and two reported findings are fixed in #1197. |
|
The #1197 CI shows one in debugger, see comment there. |
What does the geanyctags warning say? It doesn't seem to appear in the #1197 CI log. |
|
|
There are many more warnings :(. Here is the list of the remaining warnings: https://gist.github.com/eht16/1b126c77a28bae54d0fa8eb65b117c13 |
|
Well, for geanyctags it is a false positive in terms of bug detection but technically it really is "Mismatching allocation and deallocation". The Sice To eliminate the warning, the |
|
The vimode error is a false positive though. It happens for line geany-plugins/vimode/src/cmd-runner.c Line 706 in 7cb4499
but this line is only executed when |
I tried with the following changes: diff --git a/geanyctags/src/geanyctags.c b/geanyctags/src/geanyctags.c
index 2cea2246..74d80002 100644
--- a/geanyctags/src/geanyctags.c
+++ b/geanyctags/src/geanyctags.c
@@ -111,7 +111,9 @@ static void plugin_geanyctags_help (G_GNUC_UNUSED GeanyPlugin *plugin, G_GNUC_UN
static void spawn_cmd(const gchar *cmd, const gchar *dir)
{
GError *error = NULL;
+#ifndef G_OS_WIN32
gchar **argv = NULL;
+#endif
gchar *working_dir;
gchar *utf8_working_dir;
gchar *utf8_cmd_string;
@@ -162,7 +164,9 @@ static void spawn_cmd(const gchar *cmd, const gchar *dir)
msgwin_msg_add(COLOR_BLACK, -1, NULL, "%s", out);
}
+#ifndef G_OS_WIN32
g_strfreev(argv);
+#endif
g_free(working_dir);
g_free(out);
}but it results in the same warning. I guess cppcheck ignores '#ifdef`s. We can just suppress the warnings for this and also for the vimode warning. geany-plugins/geanyprj/src/Makefile.am Line 26 in 7c540bf
|
Agree. I think all these error appear now because you added the |
Oh, there's a mistake - instead of |
|
I thought |
Ah, sorry, I just got confused, you were right. |
cppcheck seems to test with different combinations of preprocessor macros. See https://cppcheck.sourceforge.io/manual.html#preprocessor-settings. However, I still don't understand why it always chokes on the But there are still a few errors left where I have no idea what the problem is and how to fix them or whether we can ignore them. Any help is much appreciated. |
|
Maybe merge #1201 and then sort out what still fails? |
If you mean the one we talked about: then I think the problem is that cppcheck doesn't find the allocation function because in https://github.com/danmar/cppcheck/blob/4ce76d0b58d1c26f906ad71180f9577f05f3642b/cfg/gtk.cfg#L702
This is all because of the |
|
Maybe is there a way to provide our own cppcheck config file where we define what we need? |
|
Why not just a suppression file? With a big comment |
|
Yeah, whatever works, I don't know cppcheck so I don't know all the options. |
Recent versions of cppcheck (2.9+) seem to require this configuration. The gtk.cfg configuration file is part of cppcheck itself. Closes geany#1196.
What a great idea, it's green! Thanks for the input, replacing the GTK library configuration with a custom one with only a few macros, worked fine. I removed all the previous suppression hints. @techee thanks for the suggestion and the great analysis above! |
Also fix a couple of new findings with current cppcheck version. Closes geany#1196.
Recently cppcheck started failing for G-P, e.g.:
I wonder why cppcheck doesn't find the macro anymore.
In the bugtracker and forums I did not find anything relevant:
https://sourceforge.net/p/cppcheck/discussion/general
https://trac.cppcheck.net/
Maybe we need to pass more include locations but then again, why now? What changed?
A full log can be found here (this is with cppcheck 2.9):
https://nightly.geany.org/debian/geany-plugins_1.38-1+20220909git4d08987-1_sid-amd64.log
(the link might break in the future, if so use the latest logfile on https://nightly.geany.org/debian/ for geany-plugins and sid)
I'm pretty sure it is cppcheck, I reproduced locally with cppcheck 2.9 while 2.8 works fine.
Does anyone has a clue?
@kugel- @elextr @techee @b4n
The text was updated successfully, but these errors were encountered: