@all
Can somebody explain this for me please. We do have such kind of structure:
// irrb header
struct IrrbHeader
{
c8 hSig[12]; // 'irrb vh.vl' eof
u32 hSigCheck;
u16 hVersion;
u16 hFill1;
u32 hFlags; // compression/encryption/endianess/int bits
c8 hCreator[32];
u32 hMeshCount;
u32 hMeshBufferCount;
u32 hCRC;
} PACK_STRUCT;
Now, we do:
struct irr::scene::IrrbHeader ih;
u32 sigCheck = MAKE_IRR_ID('i','r','r','b');
Reader = reader;
Reader->seek(0);
if(Reader->read(&ih,sizeof(ih)) != sizeof(ih))
return 0;
// sanity checks
printf("ih.hSigCheck=%s\n",&ih.hSigCheck);fflush(stdout);
if(ih.hSigCheck != sigCheck)
return 0;
printf("pass the sanity check\n");
Problem is that for both little endian (win32) and big endian (os4), we do have first normal printf as ih.hSigCheck=irrb (so it correctly reads from binary file , and correctly print what is in buffer), but then, when we do this "if(ih.hSigCheck != sigCheck)" we fail on os4, but not on win32.
Should be MAKE_IRR_ID be reversed instead, like:
#ifdef __amigaos4__
u32 sigCheck = MAKE_IRR_ID('b','r','r','i');
#else
u32 sigCheck = MAKE_IRR_ID('i','r','r','b');
#endif
or something ?
But then, maybe it better to change whole structure after loading , like after reading header, we just do something like:
#ifdef __BIG_ENDIAN__
le2be(ih.hSig[12]);
le2be(ih.hSigCheck);
le2be(ih.hVersion);
le2be(ih.hFill1);
le2be(ih.hFlags);
le2be(ih.hCreator[32]);
le2be(ih.hMeshCount);
le2be(ih.hMeshBufferCount);
le2be(ih.hCRC);
#endif
or kind of, so things will be swapped out already and no need for any more ifdefs and co ?