Hello all,

I have a little problem here, implementing save/load functions.
I need to export various data as a binary file, pieced together from different 
parts of the program.
Which all works well, except, i havent taken care of the endian issue yet (im 
building for Win and OSX universal binary).
Meaning, sharing files between ppc macs and intel machines doesnt work yet.
Sooo, obviously i need to swap the bytes, when needed... Now im wondering about 
the best way to do this.
I guess, it makes most sense to have an 'endian' bool in my file-header, which 
goes true when saving on a ppc mac (using a getEndianessRunTime() function 
which seems to work well for my purpose (just tested that)). Then, on loading 
files, swap if needed.
But, im not sure about the following:
I currently have my save-data arranged with (fix size) structs that i piece 
together , plus an optional chunk of audio data that may follow:

header
{
 bool bigEndian;
 float version;
        ...
}
main_data
{

 float some_data[64];
 etc..
}
audio-data chunks (length of which is defined in header)


Can i assume that the order within a struct is *not* affected by system 
endianess? This seems to be the case from what ive read so far and from my 
tests, but im not 100% sure yet. Second, of course this method requires that 
bool values are not affected by system endianess either. This would seem 
logical to me to be the case, but being a newby to all this, im not sure 
either. My tests failed so far, but, there might be another issue causing it 
atm (its difficult for me to test this since i dont have a ppc mac around, 
hence need to rely on files from testers etc...).
Also, am i going in a totally wrong direction here? Maybe theres a better way 
to tackle this problem ?
Im using MSVC++ on windows and XCode on Mac

Thanks alot!!

-Max
-- 
Psst! Geheimtipp: Online Games kostenlos spielen bei den GMX Free Games! 
http://games.entertainment.gmx.net/de/entertainment/games/free

Reply via email to