我可以在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 回答
- 3 回答
- 0 关注
- 592 浏览
添加回答
举报
0/150
提交
取消