
Question regarding unions and structures
I have several structures, such as the following:
typedef struct MainStruct
{
SpriteRec spriteRec;
short oldRow;
short oldCol;
short direction;
Quote:
} MainStruct, *MainStructPtr;
typedef struct Enemy1Struct
{
SpriteRec spriteRec;
short direction;
Quote:
} Enemy1Struct, *Enemy1StructPtr;
typedef struct FallingStruct
{
SpriteRec spriteRec;
short startRow;
short fallDelay;
short tileID;
short bombTimer;
short life;
Quote:
} FallingStruct, *FallingStructPtr;
I want to be able to declare a new structure that is large enough to hold
the largest of any of those structures, but *not* including the SpriteRec.
Normally, you'd do something like a union for this, but a union would
include the SpriteRec:
typedef union SpriteUnion
{
MainStruct mainStruct;
Enemy1Struct enemy1Struct;
FallingStruct fallingStruct;
Quote:
} SpriteUnion;
Is there some way to declare some sort of a structure that is
sizeof(SpriteUnion) - sizeof(SpriteRec)? It seems this would be possible
in assembly language, but so far I haven't found any way to do it in C.
-Vern
--
Replace the REPLACEME in my email address with Jensen to reply.
Visit the SpriteWorld web page: http://www.*-*-*.com/
--