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 492086 - Make headers -Wshadow clean
Make headers -Wshadow clean
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other All
: Normal enhancement
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2007-10-31 13:36 UTC by Peter Kjellerstedt
Modified: 2011-05-18 20:45 UTC
See Also:
GNOME target: ---
GNOME version: Unversioned Enhancement



Description Peter Kjellerstedt 2007-10-31 13:36:43 UTC
Please describe the problem:
We use -Wshadow by default for all of our own code. When including header files from GStreamer, e.g., gst/gst.h, there are numerous warnings regarding shadowed variable names. So much so that the use of -Wshadow is more or less prevented by the GStreamer include files. 

These warning mainly concerns variable names such as index, clock, time, link and unlink which all have a corresponding function in the standard C library which is then shadowed.


Steps to reproduce:
Compile any code which includes gst/gst.h with -Wshadow.

Actual results:
Numerous warnings regarding shadowed variables are produced.

Expected results:
A compilation without warnings.

Does this happen every time?
Yes

Other information:
We are using gcc 3.2.1 and gcc 3.4.4.
Comment 1 Tim-Philipp Müller 2008-01-07 13:01:39 UTC
I'm not sure if this is really worth the hassle seeing how many variables named "time", "clock" and "index" we'd have to rename (which also decreases readability of the code IMHO).

Other opinions?
Comment 2 Tim-Philipp Müller 2008-01-07 13:03:57 UTC
(I forgot: even if you just want the headers cleaned up so that your app compiles with -Wshadow, we'd still need to change declarations and function bodies so gtk-doc doesn't complain).
Comment 3 David Schleef 2008-01-07 22:22:14 UTC
IMO, this is a bug in gcc.  Using "index" in a prototype doesn't shadow anything, because there's no declaration of any symbol named "index".  It's just a placeholder.
Comment 4 Peter Kjellerstedt 2008-01-08 08:32:48 UTC
Unfortunately the fact that this may be considered a bug in gcc does not change the fact that including GStreamer's header files makes it useless to specify the -Wshadow flag due to the massive spam of warnings from gcc. :(

However, I did not know of the requirement from gtk-doc that the variable names in the definition and the declaration of the functions must match, which of course increases the amount of work considerably. I cannot really say if it is worth it, though. I just know that we now have one option less to avoid potential errors in our code (and yes, I have found bugs with the aid of the -Wshadow option in the past).
Comment 5 Sebastian Dröge (slomo) 2008-05-16 22:28:24 UTC
Also it should probably be noted that the GLib headers are not -Wshadow clean either... so fixing them would be the first step ;)
Comment 6 Benjamin Otte (Company) 2008-06-08 12:25:09 UTC
I investigated this a bit, and it turns out that parameter names are not causing warnings with -Wshadow in my gcc versions. See my mail at http://lists.freedesktop.org/archives/swfdec/2008-June/001643.html
Comment 7 Sebastian Dröge (slomo) 2011-05-18 20:45:54 UTC
Let's close this as obsolete then.