How to place a structure in a union

I have a union X. It is 64 bits in size. How can I write (if possible) declaring it if I want to access those 64 bits as:

 1. 4 int16_t: p,q,r,s;
 2. Array of 4 int16_t: a[4]
 3. 2 int32_t: n, m;
 4. Array of 2 int32_t: b[2]
 5. 1 int64_t z;

      

+2


a source to share


1 answer


sort of



union thingie_type {
    struct { int16_t p,q,r,s; };
    int16_t a[4];
    struct { int32_t n,m; };
    int32_t b[2];
    int64_t z;
};

      

+3


a source







All Articles