C++结构对准
我在Windows上使用Visual C ++。我有以下结构:
struct Vector3
{
float x, y, z;
};
struct Vector4
{
union
{
__m128 _xmm;
struct
{
float x, y, z, w;
};
};
}
#pragma pack(push, 1)
struct Vertex
{
Vector3 Position;
Vector4 Color;
}
#pragma pack(pop)
我需要防止在struct dertex
中进行填充,但是此代码不起作用(sizeof(vertex)== 32
,我想要sizeof( vertex)== 28
),我的想法为零。
I am using Visual C++ on Windows. I have following structs:
struct Vector3
{
float x, y, z;
};
struct Vector4
{
union
{
__m128 _xmm;
struct
{
float x, y, z, w;
};
};
}
#pragma pack(push, 1)
struct Vertex
{
Vector3 Position;
Vector4 Color;
}
#pragma pack(pop)
I need to prevent padding in struct Vertex
, but this code does not work(sizeof(Vertex) == 32
, I want sizeof(Vertex) == 28
) and I have zero ideas how to fix it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论