Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c programming q

Author: Russell Reagan

Date: 09:47:07 05/09/03

Go up one level in this thread


On May 09, 2003 at 10:28:53, Robert Hyatt wrote:

>That's a different issue, called "endianness".  However fields within a
>structure
>_must_ be ordered exactly as specified by the programmer, and I have _never_
>found a case where this was not done...
>
>With the sole exception of bit-fields...

So was it because I was compiling with gcc instead of MSVC, or because I was on
an Ultra Sparc instead of a PC? I changed the "endianness" of the move structure
and all was fine. Actually, there was only a problem with promotions I think.
Can't remember why. I had a move struct something like:

tyedef struct {
    unsigned char from;
    unsigned char to;
    unsigned char flags;
    unsigned char dummy;
} MoveStruct;

typedef union {
    MoveStruct move;
    unsigned int bits;
} Move;

Then I stuffed the promotion piece into 0xf of the flag field, and I had some
constants that I used:

#define PROMOTION 0xf
#define CAPTURE   0x10
#define CASTLE    0x20
// etc...

I only had to change the endianness of these constants and all worked well
again.



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.