Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: c programming q

Author: Gareth McCaughan

Date: 17:34:30 05/09/03

Go up one level in this thread


On May 09, 2003 at 10:26:41, Robert Hyatt wrote:

>On May 08, 2003 at 21:00:46, Zach Wegner wrote:
>
>>In my program, I have the move data structure:
>>typedef struct
>>{
>>    union
>>    {
>>        struct
>>        {
>>            char from;
>>            char to;
>>            char bits;
>>            char piece;
>>        };
>>        unsigned int move;
>>    };
>>    unsigned int score;
>>} SMOVE;
>>
>>Is there any specific order in which the chars are aligned into the int, or is
>>it compiler-dependent?
>>
>>Zach
>
>
>
>They have to be aligned left-to-right.  IE from will be the MSbyte, piece will
>be the LSbyte.

No.

They will be stored in order of increasing address. On some
architectures this will be LSB first; on others it will be MSB
first; on some weird systems it might be something different.

There may be padding anywhere within the structure, including
between those single-byte fields. In practice, there will almost
certainly be no padding between those fields.

--
g



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.