Size of structure containing vector <T> of different sizes between DLL and EXE

I have a situation where the EXE program imports a DLL for a single function call. It works by moving to a user structure and returning another user structure. Until now, it worked fine, until I wanted one of the data elements of the structures to be a <MyStruct> vector

When I do sizeof (vector <MyStruct>) in my program, I get size 20, but when I do it from within the DLL, I get size 24. This inconsistency of this size causes an ESP pointer error.

Can someone tell me why Vector <MyStruct> would be a different size in the DLL than in the program?

I read that my structures in both the DLL and the Program are identical.

I would be grateful for any help on this. Thank.

+3
source share
1 answer

I encounter a similar problem when a class has a vector member <..> and with a built-in build function (implemented in the header file). Regardless of which version of the DLL is the version or version of the dll, as if the EXE released the version, the size of this class, calculated in the EXE, is 3 bytes smaller than in the DLL, so the stack will be destroyed.

This issue can be fixed with one of the following changes:

  • This happened only with VC98 (SP6). Switch to VS2008, the problem will disappear.

  • Move the built-in design function to the CPP file, the problem will disappear
    too.

, - .

+1

Source: https://habr.com/ru/post/1746116/


All Articles