GNOME Bugzilla – Bug 492086
Make headers -Wshadow clean
Last modified: 2011-05-18 20:45:54 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.
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?
(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).
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.
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).
Also it should probably be noted that the GLib headers are not -Wshadow clean either... so fixing them would be the first step ;)
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
Let's close this as obsolete then.