[XviD-devel] how to make struct smaller
Edouard Gomez
ed.gomez at free.fr
Thu Oct 16 19:13:29 CEST 2003
Radek Czyz (syskin at ihug.com.au) wrote:
> Hi everyone,
>
> I found away to make MACROBLOCK struct much smaller. How about this:
>
> typedef struct
> {
> union {
> struct {
> ...
> };
> struct {
> ...
> };
> };
>
> } plop_t;
This is neither ANSI C nor ISO C99, union fields have to be named. But
gcc accepts them in non ISO C modes.
To be valid ISO C 89 or 99, you have to write:
typedef struct
{
int mode;
union {
struct {
int var1;
int var2;
} plop1;
struct {
int var3;
int var4;
int var5;
} plop2;
}megaplopunion;
} plop_t;
So addressing fields becomes quite annoying:
plop_t x;
x.megaplopunion.plop1.var1 = 0;
--
Edouard Gomez
More information about the XviD-devel
mailing list