6 Replies Latest reply on Oct 15, 2010 6:53 PM by himanshu.gautam

    Improving union with type ?

    spectral

      I would like to write something like that :

      typedef struct
      {
       int a;
       float b;
       float c;
      } T1;

      typedef struct
      {
       float a;
      } T2;

      typdef union
      {
       T1 t1;
       T2 t2;
      } ValuesSet;

      Like this I can access like this :

      ValuesSet set;
      set.t1.a = 20; 

      Today I have to do the following :

      typdef
      {
      union { 
       T1 t1;

       T2 t2;
      } all;
      } ValuesSet;

       set.all.t1.a = 20;

      It is a longer expression :-(