libbonoboui-2.4.3 compilation derefencing type-punned pointer warning



Hi all,

I'm compiling libbonoboui-2.4.3 and I'm consistently getting the warning:

bonobo-ui-preferences.c: In function
`bonobo_ui_preferences_get_toolbar_style':
bonobo-ui-preferences.c:172: warning: dereferencing type-punned pointer
will break strict-aliasing rules

OK, what's happening is that the function
bonobo_ui_preferences_get_toolbar_style is casting the variable "style"
(which is an enum GConfEnumStringPair) to a gint * type. (see below).
When you run gcc with -Wall this also includes -Wstrict-aliasing it
picks up that this is an "invalid" cast, even though strictly speaking
an enum is really just an int (weirdly enough gcc doesn't thinks it a
close enough type match).

Any ideas on how to resolve this particular warning? I know it's a
pretty anal thing to worry about (no compilation errors and no serious
side-effects in the executable will happen), but if the compilation is
going to spit out all warnings I'm guessing it would be nice to work out
how to remove this warning!

Chris

In bonobo-ui-preferences.c:

BonoboUIToolbarStyle
bonobo_ui_preferences_get_toolbar_style (void)
{
        BonoboUIToolbarStyle style;
        char *str;


        if (!client)
                client = gconf_client_get_default ();


        style = BONOBO_UI_TOOLBAR_STYLE_ICONS_AND_TEXT;


        str = gconf_client_get_string (client,

"/desktop/gnome/interface/toolbar_style",
                                       NULL);


        if (str != NULL) {
                gconf_string_to_enum (toolbar_styles,
                                      str, (gint *)&style);
                g_free (str);
        }


        return style;
}




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