I came across the following code, and was told that it means that COL_8888_RED
is "endian independent". Why? What makes this endian independent?
(I have asked the original coder but they're not getting back to me ... heck maybe they don't know either.)
union _colours {
uint8 c[3][4];
uint32 alignment;
};
static const union _colours col_8888 = {
{ /* B G R A in memory */
{ 0x00, 0x00, 0xFF, 0xFF, }, /* red */
{ 0x00, 0xFF, 0x00, 0xFF, }, /* green */
{ 0xFF, 0x00, 0x00, 0xFF, }, /* blue */
}
};
#define COL_8888_RED *((uint32 *)&col_8888.c[0])