array of bits field

Shiping Zhang ping at cubmol.bio.columbia.edu
Tue Feb 13 05:25:17 AEST 1990


Is there a way to define an array of bits field which are tightly packed?

I tried the following but it caused compiling error.

struct {
    int bits[16]:1;
} bits;

What I intended to do is as following:

first define an union:

union {
    int i;
    struct {
        int bits[16]:1;
    } bits;
} bits;

then assign a ingeter to bits.i;

then get the bit pattern of bits.i via using bits.bits.bits

Thanks.

-ping



More information about the Comp.lang.c mailing list