Linux: Dropping Support for GCC 2.95

Kurt Wall kwallinator
Wed Dec 14 20:02:43 PST 2005


On Wednesday 14 December 2005 07:28 am, Ben Duncan wrote:
> Ok, question:
>
> What exactly are : anonymous unions and anonymous structures?

Precisely what the names imply, unions and structures that lack
names. A named union might look like

union {
    int i;
    float f;
} u;

In this case, the name of the union is "n". Now, wrap it in a structure:

struct s {
    union {
        int i;
        float f
    } u;
};

To assign a value to i, you have to write "s.u.i = 10;".

An unnamed union would be declared:

union {
    int i;
    float f;
};

Wrapped in our structure, it looks like"

struct s {
    union {
        int i;
        float f;
    };
};

Now, to assign a value to i, you simply write "s.i = 10;". So, anonymous 
unions make it possible access union members directly rather than
through the union name.

Kurt
-- 
Real programmers don't bring brown-bag lunches.  If the vending machine
doesn't sell it, they don't eat it.  Vending machines don't sell
quiche.


More information about the Linux-users mailing list