我可以在c ++ / g ++中做到這一點:struct vec3 { union { struct { float x, y, z; }; float xyz[3]; }; };然后,vec3 v;assert(&v.xyz[0] == &v.x);assert(&v.xyz[1] == &v.y);assert(&v.xyz[2] == &v.z);將工作。用gcc在c語言中如何做到這一點?我有typedef struct { union { struct { float x, y, z; }; float xyz[3]; };} Vector3;但是我到處都有錯誤,特別是line 5: warning: declaration does not declare anythingline 7: warning: declaration does not declare anything
- 3 回答
- 0 關注
- 613 瀏覽
添加回答
舉報
0/150
提交
取消