I have this piece of code:
Code:
#define NFIELDS 4

typedef union 
{
   int Par[NFIELDS];
   struct {
      int Field1;
      int Field2;
      int Field3;
      int Field4;
   };
} Par_t;
Every time I add a new field in the struct I have to manualy set NFIELD to the right number. Every field of the struct is always int so you can access the single field or you can access through the array.
How can I get rid of the macro NFIELDS and use instead the size of the struct to avoid errors when I add a new field inside the struct?