Author: Miguel A. Ballicora
Date: 15:15:34 05/08/02
Go up one level in this thread
On May 08, 2002 at 17:34:32, Dieter Buerssner wrote:
>On May 08, 2002 at 16:07:54, martin fierz wrote:
>
>>in C, you have the easy option of defining a bitfield:
>>
>>struct
>> {
>> int i:10;
>> unsigned int j:10;
>> int k:12;
>> }
>
>It first seemed all clear. But then I looked up in the draft for the ISO C
>Standard of 99, which confused me.
>
>Under: 6.7.2.1 Structure and union specifiers
>
>8 A bit-field shall have a type that is a qualified or unqualified version of
>_Bool, signed int,or unsigned int. A bit-field is interpreted as a signed or
>unsigned integer type consisting of the specified number of bits.95) If the
>value 0 or 1 is stored into a nonzero-width bit-field of type _Bool, the value
>of the bit-field shall compare equal to the value stored.
>
>And footnote 95 reads:
>
>95) As specified in 6.7.2 above, if the actual type specifier used is int or a
>typedef-name defined as int, then it is implementation-defined whether the
>bit-field is signed or unsigned.
>
>So, it seems, that one really would need to write signed int instead of int. Or
>am I misunderstanding something here?
Yes, it is like char. Very important detail! it is good to spell these things
out and use either signed or unsigned. I am not a C expert but I have seen
this mention on comp.lang.c zillions of times (BTW, I learned a _LOT_ in that
newsgroup, I strongly recommend it).
Regards,
Miguel
>
>Regards,
>Dieter
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.