GNOME Bugzilla – Bug 541598
using old style casts in public headers
Last modified: 2012-05-28 19:56:47 UTC
I work on a project where other people have decided to use the g++ compile flag '-Wold-style-cast'. In several public gtkmm header files old style casts are being used, which generates a fairly large amount of warnings. Would it be possible to use C++ casts in the gtkmm headers to avoid these warnings? To see the problem compile the following simple program: #include <gtkmm.h> int main (int argc, char *argv []) { return 0; } with the -Wold-style-cast flag. In case you don't want to spend time on compiling this program I'm attaching the warnings.
Created attachment 114001 [details] The generated warnings
Sure a patch (against svn) would be welcome.
unfortunately, I don't believe it will be simple to completely get rid of these errors. for example, the first warning shown refers to the following line in unicode.h: inline bool isalnum(char c) { return g_ascii_isalnum(c); } g_ascii_isalnum() is a macro defined in glib/gstrfuncs.h as: #define g_ascii_isalnum(c) \ ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0) So the cast is happening in the glib C code. The only way to get rid of this cast in glibmm headers is to move the definition of isalnum() to the source file (i.e. make it non-inlined). But this doesn't seem like a good idea from a performance point of view. There are other macros such as g_list_next() which contain embedded old-style casts that we use in other headers. So if we can't competely get rid of these warnings, I don't think it really makes sense to spend a lot of time looking for all of them. However, if you would like to submit a patch to clean up the ones we have control over, we'd be willing to apply it.
A patch would still be welcome. Otherwise I will close this bug soon as obsolete.
Closing due to the lack of response.