After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635869 - GST_BOILERPLATE_FULL causes warnings in user C++ code
GST_BOILERPLATE_FULL causes warnings in user C++ code
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
0.10.29
Other Linux
: Normal normal
: 0.10.31
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2010-11-26 18:33 UTC by Thiago Macieira
Modified: 2010-11-29 12:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
utils: avoid 'unused argument' warnings caused by GST_BOILERPLATE_FULL (1.57 KB, patch)
2010-11-27 19:17 UTC, Tim-Philipp Müller
committed Details | Review

Description Thiago Macieira 2010-11-26 18:33:23 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;
Comment 1 Olivier Crête 2010-11-26 19:33:30 UTC
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.
Comment 2 Thiago Macieira 2010-11-26 21:17:52 UTC
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
Comment 3 Tim-Philipp Müller 2010-11-27 19:17:03 UTC
Created attachment 175374 [details] [review]
 utils: avoid 'unused argument' warnings caused by GST_BOILERPLATE_FULL

How about this?
Comment 4 Thiago Macieira 2010-11-29 10:55:03 UTC
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).
Comment 5 Tim-Philipp Müller 2010-11-29 11:59:00 UTC
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.
Comment 6 Thiago Macieira 2010-11-29 12:24:37 UTC
(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.
Comment 7 Tim-Philipp Müller 2010-11-29 12:37:13 UTC
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