
Hello!
Wolfgang Denk schrieb:
Oops? I can't parse that. What's the difference between "signed char" and "int" except the number of bits?
Like mentioned before, accessing data via a (signed|unsigned|.) char * is independant of the processor endianess. If you want to read a bitstream which is bytewise formatted you don't want to care about endianess. Or do you also want some endianess string definitions?
#ifdef __LITTLE_ENDIAN const char my_text[] = "sihT si xe a \0\0te"; #endif #ifdef __BIG_ENDIAN const char my_text[] = "This is a text"; #endif
int * p_text = (int *)my_text;
And it is even worse; on some architectures, like ARM, it is not allowed to do a 16/32 bit memory access on a non-aligned address, e.g.:
int val; int * p_data;
p_data = (int *)0x23400001; val = *p_data;
Depending of the ARM implementation you either get a data abort or an "implementation depending" wrong value in val. For write access it is even worse because this can overwrite some memory.
With best regards Andreas Schweigstill