Re: gtk-demo uses private fields



On Fri, 2001-11-09 at 20:47, Darin Adler wrote:
> 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.

Thanks a lot for that. I guess that it's not a problem that these guints
are set from gbooleans? This must be very common.

-- 
Murray Cumming
murrayc usa net
www.murrayc.com




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