Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitfields and Crafty

Author: Heiner Marxen

Date: 14:43:17 07/17/01

Go up one level in this thread


On July 17, 2001 at 16:38:39, Chris Hull wrote:

>On July 16, 2001 at 15:38:10, Dann Corbit wrote:
>
>>On July 16, 2001 at 14:58:04, Tord Romstad wrote:
>>
>>>On July 11, 2001 at 23:36:39, Robert Hyatt wrote:
>>>
>>>>2.  The ANSI standards committee did the same stupid thing with bit fields that
>>>>they did with other key issues, "this is left to the vendor's discretion..."
>>>>Ie is a char signed or unsigned by default?  Depends on the compiler.
>>>
>>>Please tell me you are just kidding.  I have always assumed that chars are
>>>signed by default, and a lot of my code depends on it.  Are you saying that
>>>my code could stop working when I switch to another compiler?
>>
>>No.  Unadorned char is either signed or unsigned, depending upon the
>>implementation.  The reason for strange things like this is preexisting code.
>>Imagine you have have a collection of hundreds of thousands of lines of code,
>>and suddenly a restriction is imposed which breaks it.
>>
>>Personally, I would have gone ahead and broken all of the code.  After all:
>>
>>int foo;
>>long bar;
>>
>>do not leave the signed nature of foo and bar up to chance for whatever compiler
>>is used, they must be signed
>
>If you don't want to leave it up to chance use
>
>signed int foo;
>signed long bar;
>unsigned int ufoo;
>unsigned long ubar;
>
>If not you rolls the dice, you take your chances.
>
>Chris Hull

NO, please do not!

The only C type the signedness of which is not defined by the language
proper is char.  This is the only exception, all other (integral) types
have a well defined signedness.  int is always signed.

To get a signed char write

signed char	foo;

Otherwise the keyword 'signed' is useless.  All of int, short and long
are signed, already.

Ah, and yes, there are compilers, which make plain 'char' unsigned.

Regards,
Heiner



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.