gcc is fond of complaining about punned pointers. What it is complaining about is the technique of casting a structure to another structure using pointers to stop the compiler complaining. For instance, say we have a RECT and an AREA as below, we can reasonably interchange them as they have the same layout.
struct RECT { struct AREA {
int left; int x;
int top; int y;
int bottom; int height;
int right; int width;
}; };
So we might pass data in an AREA to some function that wants RECT using
function_wanting_area(*(RECT *)&area);
To avoid this error and let the compiler know that these two types are actually the same thing we can use a union to do the conversion instead. This is basically how to shut the compiler up and let it do more optimization.
union SWAPRECTAREA {RECT rect; AREA area;};
funtion_wanting_area(((union SWAPRECTAREA)area).rect);
I saw this someplace which can make this a bit easier to use:
#define UNION_CAST(x, sourceType, destType) (((union {sourceType a; destType b;})x).b)
ie: RECT rc = UNION_CAST(area, AREA, RECT);