GNOME Bugzilla – Bug 635869
GST_BOILERPLATE_FULL causes warnings in user C++ code
Last modified: 2010-11-29 12:37:13 UTC
When user C++ code has: GST_BOILERPLATE (ArtsSink, arts_sink, GstAudioSink, GST_TYPE_AUDIO_SINK) The C++ compiler (but not the C compiler) will generate a warning for unused parameters: artssink.cpp:83:242: warning: unused parameter 'data' This warning is not fixable from user code. Suggestion: add to the macro at any point in the function body: (void) data;
There is a G_GNUC_UNUSED macro that can be used in the parameter declaration to quiet that warning instead of doing that ugly hack. That said, most GObject code should be compiled with -Wno-unused-parameter.
G_GNUC_UNUSED might be good, but we used GStreamer with other compilers too. If possible, please fix it for the general case. Anyway, this is the only warning we're getting from the GStreamer headers. I haven't seen any other problem coming from GStreamer or GObject that would require -Wno-unused-parameter. That said, I did add -Wno-error=unused-parameter to my flags. Downstream bug: http://bugreports.qt.nokia.com/browse/QTBUG-5915
Created attachment 175374 [details] [review] utils: avoid 'unused argument' warnings caused by GST_BOILERPLATE_FULL How about this?
The warning is gone with this patch. I have no idea whether the patch is the proper way to do it (removing the argument sounds scary).
It's fine, the C calling convention allows you to pass extra arguments, it's not uncommon to do things like g_list_free (list, (GFunc) g_free, NULL); for example. I admit it's not very nice, but at least it's guaranteed to avoid the warning with every compiler.
(In reply to comment #5) > It's fine, the C calling convention allows you to pass extra arguments, it's > not uncommon to do things like > > g_list_free (list, (GFunc) g_free, NULL); > > for example. I admit it's not very nice, but at least it's guaranteed to avoid > the warning with every compiler. Well, as long as no one is crazy enough to change the calling convention. Sometimes people try to do that: http://bugreports.qt.nokia.com/browse/QTBUG-13823 http://bugreports.qt.nokia.com/browse/QTBUG-5399 (reports appropriately closed with Won't Fix / Out of Scope) Thanks for the patch.
If someone does that, this macro is the least of their worries - lots of code in GLib/GStreamer ladn depends on that. commit 5cac98714816b6c5f52caace9bf33146d9826d07 Author: Tim-Philipp Müller <tim.muller@collabora.co.uk> Date: Sat Nov 27 19:13:35 2010 +0000 utils: avoid 'unused argument' warnings caused by GST_BOILERPLATE_FULL The unused data parameter in the class_init trampoline function seems to cause warnings with some c++ compilers. https://bugzilla.gnome.org/show_bug.cgi?id=635869