I need to read in unsigned char * bytes which are in reverse order to the native order. At the moment I have lots of little routines along the following lines:
uint8_t * bytes;
uint32_t r;
bytes = pt;
r = (((((bytes[0] << 8) + bytes[1]) << 8) + bytes[2]) << 8) + bytes[3];
pt += 4;
return r;
Is there a standard or portable way to do this kind of job, or do I have to hack up functions like this?