__declspec(align(x)) and virtual tables
- From: "Gabriel Cote" <gabriel.cote_remove_that_part_@xxxxxxx>
- Date: Wed, 14 Dec 2005 17:27:32 -0500
HI,
I have a class with a virtual table that also has a member that is aligned on 16 bytes : __declspec(align(16)) . The problem is that the virtual table is padded to a size of 16 bytes even if the first member of the class is not the aligned one?!? Is there a way (like a command option) to deactivate this feature, so I can use the lost 12 bytes?
Here is a small exemple of my problem:
///////////////////////////////////////////////
__declspec(align(16))
struct Vector4
{
float x;
float y;
float z;
float w;
};struct MyStruct
{
virtual ~MyStruct() {}int* ptr; // expected to have it right after the virtual table ptr, but is instead aligned on 16 bytes
Vector4 vec;
};
///////////////////////////////////////////////
I was expecting to have 'MyStruct' and 'MyStruct::vec' aligned on 16 bytes, but not 'MyStruct::ptr'.
BTW, I'm using VisualStudio 2005.
Thanks, Gabriel .
- Follow-Ups:
- Re: __declspec(align(x)) and virtual tables
- From: Ulrich Eckhardt
- Re: __declspec(align(x)) and virtual tables
- Prev by Date: Re: Throwing exception from _invalid_parameter_handler
- Next by Date: Re: Throwing exception from _invalid_parameter_handler
- Previous by thread: Throwing exception from _invalid_parameter_handler
- Next by thread: Re: __declspec(align(x)) and virtual tables
- Index(es):
Relevant Pages
|