32 vs. 64 bit binary files

Brian McGrew brian@visionpro.com
Wed Nov 11 23:22:00 GMT 2009


So we've run into our first real snag on the conversion road from 32 to 64
bit.  We write out a binary file full of data and then read it back in using
fwrite and fread.

My file format is pure binary and it's as follows:

Long height
Long width
For (short; height * width)
Long
Long

So in the 32 bit world, this works great.  But when trying to read these 32
bit files into software on the 64 bit systems, I'm running into problems!

There are no delimeters in my file that I can use to determine which arch
the file was written on.

What I need is some kind of method to determine the arch, possibly based on
the file???  I don't know???  All I need to know is, from the code level, if
it's a 32-bit binary file or a 64-bit binary file?

Thanks,

-b



More information about the Gcc-help mailing list