c++ - Data conversion for ARM platform (from x86/x64) -
we have developed win32 application x86 , x64 platform. want use same application on arm platform. endianness vary arm platform i.e. arm platform uses big endian format in general. want handle in our application our device.
for e.g. // in x86/x64, int nintval = 0x12345678
in arm, int nintval = 0x78563412
how values stored following data types in arm?
- double
- char array i.e. char chbuffer[256]
- int64
please clarify this.
regards, raphel
endianess matters register <-> memory operations.
in register there no endianess. if put
int nintval = 0x12345678
in code have same effect on endianess machine.
all ieee formats (float
, double
) identical in architectures, not matter.
you have care endianess in 2 cases:
a) write integers files have transferable between 2 architectures. solution: use hton*, ntoh*
family of converters, use non-binary file format (e.g. xml) or standardised file format (e.g. sqlite).
b) cast integer pointers.
int = 0x1875824715; char b = a; char c = *(char *)&a; if (b == c) { // working on little endian }
the latter code way handy way of testing endianess @ runtime.
arrays , likes if use write, fwrite
falimies of calls transfer them have no problems unless contain integers: above.
int64_t
: above. care if have store them binary in files or cast pointers.
Comments
Post a Comment