Re: gtk-demo uses private fields



on 11/9/01 11:54 AM, Murray Cumming at murrayc t-online de wrote:

> I don't understand. Please elaborate.

If you define something like this:

    struct x {
        int b : 1;
    };

Then b will contain either 0 or -1 (at least with gcc), not 0 or 1 as you
probably want. So this:

    struct x {
        gboolean b : 1;
    };

Is a bad idea, and can lead to annoying bugs. Thus in glib we use:

    struct x {
        guint b : 1;
    };

Eel has eel_boolean_bit as a typedef for guint, but the glib folks found
that ugly and decided not to add something like that.

An alternative would be to have gboolean be guint instead of int, but it's
far too late in the backward-compatibility day for that to be changed, I
imagine.

    -- Darin




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