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 541598 - using old style casts in public headers
using old style casts in public headers
Status: RESOLVED OBSOLETE
Product: gtkmm
Classification: Bindings
Component: general
unspecified
Other Linux
: Normal minor
: ---
Assigned To: gtkmm-forge
gtkmm-forge
Depends on:
Blocks:
 
 
Reported: 2008-07-04 20:29 UTC by søren hauberg
Modified: 2012-05-28 19:56 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
The generated warnings (11.98 KB, text/plain)
2008-07-04 20:31 UTC, søren hauberg
Details

Description søren hauberg 2008-07-04 20:29:52 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.
Comment 1 søren hauberg 2008-07-04 20:31:25 UTC
Created attachment 114001 [details]
The generated warnings
Comment 2 Murray Cumming 2008-07-11 21:51:47 UTC
Sure a patch (against svn) would be welcome.
Comment 3 Jonathon Jongsma 2008-07-26 12:55:02 UTC
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.
Comment 4 Murray Cumming 2011-11-18 08:25:59 UTC
A patch would still be welcome. Otherwise I will close this bug soon as obsolete.
Comment 5 Murray Cumming 2012-05-28 19:56:47 UTC
Closing due to the lack of response.