Can I treat a struct like an array?

前端 未结 8 1632
野趣味
野趣味 2020-12-03 18:11

I have a struct for holding a 4D vector

struct {
    float x;
    float y;
    float z;
    float w;
} vector4f

And I\'m using a library th

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-03 18:50

    It might work but it is not portable, the compiler is free to align things so that one float does not neccessarily immediately follow the other.

提交回复
热议问题