Re: gboolean definition and size
- From: Owen Taylor <otaylor redhat com>
- To: Dan Nicolaescu <dann godzilla ICS UCI EDU>
- Cc: gtk-devel-list gnome org
- Subject: Re: gboolean definition and size
- Date: 12 Sep 2001 19:55:01 -0400
Dan Nicolaescu <dann godzilla ICS UCI EDU> writes:
> Hi!
>
> gboolean is currently defined as an int.
>
> The C99 standard contains now a standard boolean size, and it's _not_
> int size.
>
> gcc-3.x defines a magic type _Bool that is used to define the bool
> type. It's size is 1 byte.
>
> Is there any reason for gboolean to have a different size?
>
> IMHO it should be defined in such a way that it makes interoperability
> with C99 code easy.
>
> Probably gboolean should be defined as _Bool when using gcc-3.x
> Another reason is that in the future compilers might have
> special optimizations for bool types...
>
> As changing the definition of gboolean is a binary incompatible
> change, it's probably a good idea to do it before releasing gtk-2.0 ...
>
>
> I tried to search the mailing list archive, and didn't find any
> discussion of this, I hope it has not been beaten to death in the
> past...
Yes, it was beaten to death in the past. Unfortunately, the archive
search is not working currently.
The basic problem with the bool definition without compiler support
for a real bool type (no stdbool.h doesn't give that) is things like:
gboolean foo = flags & MY_FLAG;
And other such less obviously wrong expressions. Making it a guint
to help with bitfield expressions is more of a possible compatible
change, but I sort of like keeping it as simple as possible.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]