How to know that which variable from Union is Used?

后端 未结 6 972
北荒
北荒 2021-02-01 22:32

If I declare a Union as:

union TestUnion
{
    struct 
    {
      unsigned int Num;
      unsigned char Name[5];
    }TestStruct;
    unsigned char Total[7];
};         


        
6条回答
  •  情话喂你
    2021-02-01 22:56

    There is no way to tell. You should have some additional flags (or other means external to your union) saying which of the union parts is really used.

提交回复
热议问题