Vanilla List Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [VANILLA-LIST:3131] Binary portability



On Sam, 06 Mai 2000 you wrote:
>Dave Ahn <ahn@vec.wfubmc.edu> wrote:
>>
>> This is a question of endianness not Windows vs Unix.
>
>Yeah I know but I read that most Unixes were one endian and Windows another.

No the endian stuff is a processor property. Intel and Sun Sparcs are little
endian, Mips vor example big endian.

So if it works for Linux then it works for Windows as well.

>> The netrek packets are translated from host to network byte order
>> before transmission.  The recipient takes the bytestream and
>> converts it back to its own host byte order before using the values.
>
>Ok, that explains how the network works for endiannes.
>
>> You may be getting an extra byte swap in the cambot file.  Since I haven't
>> looked at the server and client cambot code, I couldn't say for sure.
>
>There shouldn't be any swapping done, because the packets that are
>written to the cambot file have not gone through the network.

I hope the will go to file after byte swapping if they go as byte stream to
file. If they will be saved as int stream, byte swapping will be done on the
file IO level automatically as well.

>My compiler is leaving holes in structures, which is wasting space and
>preventing ``binary'' I/O to external data files. Can I turn off the
>padding, or otherwise control the alignment of structure fields?

Usually you can do that either with a pragma pack option or a compiler flag.

Kurt (007)

-- 
Kurt Siegl / Franzberg 4, A-4483 Hargelsberg, Austria
Email: Kurt.Siegl@freemail.at  Tel (ISDN):   *(7225)7017
URL:   http://members.aon.at/presents/siegl/kurt/