Re: Deferencing type-punned pointers, and how to stop gcc giving youa warning

I understand... some of the patches I've put in bugzilla are kind of ugly, especially the gdk x11 stuff! I was even seriously considering making a *macro* that did it for me... but discarded this as somewhat stupid. I only want to say one last thing, before I ever hold my piece: I'm just a tad worried that we're sticking our heads in the sand. I'd always thought that it's best to get rid of compiler warnings, if only to potentially stop things from breaking further down the track.

I do notice that Owen has accepted/created patches for pango that do much the same as I'm doing. Should we be? And if we have, shouldn't we be reversing them then as we're making the code harder to maintain?

The question is... would it be better to set the following compiler flags:

-Wno-strict-aliasing (from memory)

Or even compile at only -O. Nah. Not that one.

Here's another thing I'd like to know: why did C99 even come up with strict aliasing? was it to improve performance? If so, maybe a small amount of reorganisation of code could be in order (perhaps - I'm more musing out loud and wouldn't really know how to go about doing it).

One last thing: half these warnings wouldn't happen if we knew what standard we were compiling to: C89 or C99. I asked on #gnome-hackers the other night and I got two responses. jdub said it was undefined (lovely word that) but then suggested we compile to C89 to try to keep max compatibility. In which case the -ansi tag would be the go. Of course, if we compile to C89, what features and advantages of C99 are we missing out on?

Anyway, please try to remember I'm kind of new to gnome hacking, and mainly tried to resolve the warnings as my first foray into contributing to the GNOME community. So go easy on the flames! Try to remember I am a precious and unique snowflake and I can't take the heat.


Morten Welinder wrote:
Glib and GTK+ violate the C standards in many different ways.  It's
probably not useful at this point to expect compliance.

For example, I believe that are quite a few places that will be
unhappy if a void* cannot hold a function type pointer.  They
are, after all, not required to even have the same size.

Consequently I believe that these warnings should be eliminated
using as few casts as possible.  Casts are truly a maintenance
nightmare.  If there is a way to simply make gcc shut up, then
I think that is the way to go.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]