I ran into the problem of interaction between C # and C ++, where I share memory between the two "sides" of my application through a structure defined in both native and managed code. The structure on the native side is defined as such:
#pragma pack(push, 1)
struct RayTestCollisionDesc {
btVector3 hitPosition;
btRigidBody* hitBody;
RayTestCollisionDesc(btRigidBody* body, btVector3& position)
: hitBody(body), hitPosition(position) { }
};
#pragma pack(pop)
And a similar structure is defined on the managed (C #) side. In C #, the size of the structure is 20 bytes (as I would expect on a 32-bit system). However, despite the directive pragma pack, the size of the structure in C ++ - the size is 32. For clarity, here sizeof()from C ++ each of these types:
sizeof(btVector3) : 16
sizeof(btRigidBody*) : 4
sizeof(RayTestCollisionDesc) : 32
, pragma pack , (.. ). __declspec(align(1)), , MSDN : "__declspec (align (#)) ".
FWIW VS2013 (Platform Toolset v120).
"" 20 ?