Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Yet another GCC question

Author: Steven Edwards

Date: 09:27:35 12/06/03

Go up one level in this thread


On December 05, 2003 at 21:24:19, Robert Hyatt wrote:

>I have a structure that looks like this:
>
>struct BOOK_POSITION {
>  long long signature;
>  unsigned int status;
>  float learn;
>  int CAP;
>}
>
>sizeof(above) gives 20 on my dual xeon, 24 on the
>opteron.  I'd like to make it 20 so that my binary book
>can be shared between the opteron and the rest of the
>intel world.
>
>Is there a reasonably portable way to fix this???

Yes, if you are willing to accept a small amount of overhead.

My program Symbolic uses the same opening book binary file format on both PPC
and x86 platforms,  I have placed an I/O wrapper on the CTBookEntry class (a
class similar in spirit to Crafty's BOOK_POSITION struct) that performs the
functional equivalent of the host-to-network and network-to-host mapping.  See
the man page for htons() for an example.

The book file record is neither the same layout or even size as the in-memory
record; the in-memory record is (obviously) different for different endian
platforms.

The alternative of having differing binary data file formats for different
platforms (32/64 bit, iAPX/PPC) is guaranteed to cause a headache to some
misfortunate end user.



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.