Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Bitfields and Crafty

Author: Chris Hull

Date: 13:38:39 07/17/01

Go up one level in this thread


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


>
>You can get a copy of the ANSI and ISO standards for $18 in PDF format and it
>will prevent you from discovering a lot of headaches later.
>
>You can get a pre-ratified draft of the standard for free.



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.