httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@algroup.co.uk>
Subject Re: bitfields and negative
Date Sat, 07 Mar 1998 17:54:15 GMT
Marc Slemko wrote:
> 
> On Sat, 7 Mar 1998, Ben Laurie wrote:
> 
> > typedef int BOOL;
> >
> > struct thing
> >       {
> >       BOOL x:1;
> >       };
> >
> > BOOL Compare(struct thing *p,BOOL b)
> >       { return p->x == b; }
> >
> > Why? Coz TRUE is 1, but a one bit signed bitfield can only have values 0
> > and -1.
> 
> My understanding was that some compilers default to signed, some default
> to unsigned if it is not specified...

What, in a bitfield? News to me... but you appear to be right. K&R say
"for portability, specify signed and unsigned explicitly". Damned stupid
thing to say, but there we are.

Cheers,

Ben.

--
Ben Laurie                Phone: +44 (171) 460 4460
Lead Architect            Fax:   +44 (171) 460 4461
Orchestream Ltd.
London, England.

-- 
Ben Laurie            |Phone: +44 (181) 735 0686|  Apache Group member
Freelance Consultant  |Fax:   +44 (181) 735 0689|http://www.apache.org
and Technical Director|Email: ben@algroup.co.uk |
A.L. Digital Ltd,     |Apache-SSL author    http://www.apache-ssl.org/
London, England.      |"Apache: TDG" http://www.ora.com/catalog/apache

Mime
View raw message