??? 02/13/09 14:26 Read: times |
#162359 - Can be portable Responding to: ???'s previous message |
It's just a matter of endian-ness. I use the pre-processor to sort out endian differences according to which compiler I'm using.
typedef union { uint16_t d; uint8_t b[2]; } UU16; typedef union { uint32_t l; uint16_t d[2]; uint8_t b[4]; } UU32; #ifdef LITTLE_ENDIAN #define U16_LSB 0 #define U16_MSB 1 #define U32_LSW 0 #define U32_MSW 1 #define U32_SB0 0 #define U32_SB1 1 #define U32_SB2 2 #define U32_SB3 3 #endif |
Topic | Author | Date |
LSB byte of 24 bits | 01/01/70 00:00 | |
a union | 01/01/70 00:00 | |
union = fast, but not portable | 01/01/70 00:00 | |
Shift-and-Mask = Portable, and possibly not slow | 01/01/70 00:00 | |
Shifts and masks often resulting in optimum native code | 01/01/70 00:00 | |
can be portable | 01/01/70 00:00 | |
Can be portable | 01/01/70 00:00 | |
More to it than that! | 01/01/70 00:00 | |
which is why I do this very thing | 01/01/70 00:00 | |
for completeness there is the pointer | 01/01/70 00:00 | |
Split the word? | 01/01/70 00:00 | |
Tautology? | 01/01/70 00:00 | |
re: Tautology | 01/01/70 00:00 | |
possible, but not universal![]() | 01/01/70 00:00 | |
thank you | 01/01/70 00:00 |