次のように、構造体内の共用体の宣言を見てきました。以下にサンプルコードを示します。
私の質問は、メモリの節約に役立ちますか(ユニオンが使用される典型的な用途)? メリットがわかりません。
typedef struct
{
int x1;
unsigned int x2;
ourstruct1 ov1;
ourstruct1 ov2;
union
{
struct
{
mystruct1 v1;
mystruct2 v2;
mystruct3 v3;
int* ctxSC;
mystruct4 v4;
Bool v5;
Long v6;
Long v7;
Long v8;
Long v9;
}mystr;
};
}structvar1;
-広告