Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary Files on 32bit / 64bit systems?

I am using python struct module to create custom binary files.

The file itself has the following format:

4 bytes (integer) 1 byte (unsigned char) 4 bytes (float)

4 bytes (integer) 1 byte (unsigned char) 4 bytes (float)

.......................... (100000 such lines)

4 bytes (integer) 1 byte (unsigned char) 4 bytes (float)


Currently, I am using a 32bit machine to create these custom binary files. I am soon planning on switching to a 64bit machine.

Will I be able to read/write the same files using both {32bit / 64bit} machines? or should I expect compatibility issues?

(I will be using Ubuntu Linux for both)

like image 213
user3262424 Avatar asked Feb 15 '26 21:02

user3262424


1 Answers

As long as your struct format string uses "standard size and alignment" (< or >) rather than "native size and alignment" (@), your files can be used cross-platform.

like image 146
dan04 Avatar answered Feb 18 '26 11:02

dan04



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!