interoperable data formats (was: Re: sizeof(bool))

2002-12-12 Thread guy keren
On Wed, 11 Dec 2002, Muli Ben-Yehuda wrote: > And if you can, use XDR (External Data Representation). Standard is > always good. http://www.faqs.org/rfcs/rfc1014.html. the problem with this specification is it is wasteful in network resources, because it uses a lot of padding for small data ty

Re: sizeof(bool)

2002-12-11 Thread Guy Baruch
man gcc gives : -- -fshort-enums Allocate to an enum type only as many bytes as it needs for the declared range of possible values. Specifically, the enum type will be equivalen

Re: sizeof(bool)

2002-12-11 Thread Oleg Goldshmidt
Guy Baruch <[EMAIL PROTECTED]> writes: > redefine as: > > enum bool {FALSE; TRUE}; I don't think you can do that with bool, which is a reserved word in C++. You will need #define bool mybool or equivalent first, which is, well... > then compile with > > gcc -fshort-enums s/gcc/g++/ > (whi

Re: sizeof(bool)

2002-12-11 Thread herouth
Quoting Guy Baruch <[EMAIL PROTECTED]>: > redefine as: > > enum bool {FALSE; TRUE}; > > then compile with > > gcc -fshort-enums > > (which will make _all_ your enums short => non-alligned.) I'm pretty sure that you're mistaken. My PPC box is at home so I can't test this, but I'm pretty sure t

Re: sizeof(bool)

2002-12-11 Thread Guy Baruch
redefine as: enum bool {FALSE; TRUE}; then compile with gcc -fshort-enums (which will make _all_ your enums short => non-alligned.) Michael Sternberg wrote: I'm wondering why sizeof(bool) is 1 byte in Intel platform and 4 bytes on PPC ? Is it depends on version of gcc (2.95.3 on Int

Re: sizeof(bool)

2002-12-11 Thread Muli Ben-Yehuda
On Wed, Dec 11, 2002 at 11:31:08AM +0200, [EMAIL PROTECTED] wrote: > If Michael's intention is to use the struct to transfer information from one > architecture to the other, then you're absolutely right. Endianity is the > *first* thing to consider - Motorola is always the reverse of Intel. To tr

Re: sizeof(bool)

2002-12-11 Thread herouth
Quoting Gilad Ben-Yossef <[EMAIL PROTECTED]>: [snip] > But now let's do it back wards - assign the value of IA32 and test for > it on PPC. On IA32 we put NULL in *first* of the bytes and leave junk in > the other 3 padding bytes. On the PPC we then test whether these *four* > bytes are zero. Bec

Re: sizeof(bool)

2002-12-11 Thread Gilad Ben-Yossef
On Wed, 2002-12-11 at 11:31, [EMAIL PROTECTED] wrote: > > But now let's do it back wards - assign the value of IA32 and test for > > it on PPC. On IA32 we put NULL in *first* of the bytes and leave junk in > > the other 3 padding bytes. On the PPC we then test whether these *four* > > bytes are zer

Re: sizeof(bool)

2002-12-11 Thread Oleg Goldshmidt
Michael Sternberg <[EMAIL PROTECTED]> writes: > I'm wondering why sizeof(bool) is 1 byte in Intel platform and 4 bytes on > PPC ? Is it depends on version of gcc (2.95.3 on Intel, 2.96 on PPC) > ? Can I somehow (some compiler flag) make them of same size ? No. At the very l

Re: sizeof(bool)

2002-12-11 Thread Gilad Ben-Yossef
On Wed, 2002-12-11 at 10:24, Michael Sternberg wrote: > > Gilad Ben-Yossef wrote: > > Furthermore, relying on 'int', 'bool' and friends to be ANY specific > > size is bad and broken programing and will prevent you to port the > > program to other ARCHs even with the same compiler etc. > > While I

Re: sizeof(bool)

2002-12-11 Thread Michael Sternberg
Gilad Ben-Yossef wrote: > Furthermore, relying on 'int', 'bool' and friends to be ANY specific > size is bad and broken programing and will prevent you to port the > program to other ARCHs even with the same compiler etc. While I agree with Gilad, just as service to public here is solution: stru

Re: sizeof(bool)

2002-12-11 Thread Muli Ben-Yehuda
On Wed, Dec 11, 2002 at 07:40:35AM +, Michael Sternberg wrote: > > I'm wondering why sizeof(bool) is 1 byte in Intel platform and 4 bytes on > PPC ? My guess is alignment. > Is it depends on version of gcc (2.95.3 on Intel, 2.96 on PPC) ? Certainly might be, although it

Re: sizeof(bool)

2002-12-11 Thread Gilad Ben-Yossef
On Wed, 2002-12-11 at 09:40, Michael Sternberg wrote: > > I'm wondering why sizeof(bool) is 1 byte in Intel platform and 4 bytes on > PPC ? Is it depends on version of gcc (2.95.3 on Intel, 2.96 on PPC) ? > Can I somehow (some compiler flag) make them of same size ? > Th

Re: sizeof(bool)

2002-12-11 Thread herouth
Quoting Michael Sternberg <[EMAIL PROTECTED]>: > > I'm wondering why sizeof(bool) is 1 byte in Intel platform and 4 bytes on > PPC ? Is it depends on version of gcc (2.95.3 on Intel, 2.96 on PPC) ? > Can I somehow (some compiler flag) make them of same size ? Just an e

sizeof(bool)

2002-12-10 Thread Michael Sternberg
I'm wondering why sizeof(bool) is 1 byte in Intel platform and 4 bytes on PPC ? Is it depends on version of gcc (2.95.3 on Intel, 2.96 on PPC) ? Can I somehow (some compiler flag) make them of same size ? = To unsubscribe,