Author: Leen Ammeraal
Date: 09:46:49 05/09/03
Go up one level in this thread
On May 09, 2003 at 10:27:43, Robert Hyatt wrote:
>On May 09, 2003 at 01:06:21, Leen Ammeraal 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
>>
>>It is compiler dependent.
>>Leen
>
>
>It can't be. Only bit-fields are left to the compiler to decide which end to
>start from. If the above was compiler dependent it would be _impossible_ to
>read in data files produced by another compiler on the same machine...
You are right with regard to the order (from, to, bits, piece in
the example). I was thinking of the 'endian problem' as you
refer to yourself in your other posting. Also, there may be
holes in memory between the components of a structure, although
it is unlikely that any compiler will use holes
in the current case. But in general, the size of a struct may
be larger than the sum of the sizes of the components.
I suppose you knew this already.
Leen
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.