| ??? 01/22/08 08:15 Read: times |
#149820 - Portable unions Responding to: ???'s previous message |
To make unions more portable, I use macros that explicitly encapsulate compiler endian-ness.
#ifdef SDCC
#define LITTLE_ENDIAN
#endif
typedef signed char Int8;
typedef unsigned char UInt8;
typedef signed short Int16;
typedef unsigned short UInt16;
typedef union {
Int16 d;
Int8 b[2];
} U16;
typedef union {
UInt16 d;
UInt8 b[2];
} UU16;
#ifdef LITTLE_ENDIAN
#define U16_LSB 0
#define U16_MSB 1
#endif
|
| Topic | Author | Date |
| SDCC, copying integer in ASM | 01/01/70 00:00 | |
| Shift-and-mask, or union | 01/01/70 00:00 | |
| I used asm tag and the rr command but.... | 01/01/70 00:00 | |
| Your question | 01/01/70 00:00 | |
| Portable unions | 01/01/70 00:00 | |
| Less non-portable? | 01/01/70 00:00 | |
| Less non-portable | 01/01/70 00:00 | |
| portable, schmortable | 01/01/70 00:00 | |
| Disagree! | 01/01/70 00:00 | |
| how portable? | 01/01/70 00:00 | |
| emphasis | 01/01/70 00:00 | |
Real world portable | 01/01/70 00:00 | |
| using - does not give the same result | 01/01/70 00:00 | |
| try this | 01/01/70 00:00 | |
| You are exceeeding 2 byte signed integer limits | 01/01/70 00:00 | |
| Fighting the tools | 01/01/70 00:00 | |
| Thanks all. | 01/01/70 00:00 | |
| Dangerous | 01/01/70 00:00 | |
| Very important warning! | 01/01/70 00:00 |



