Click here to Skip to main content
15,949,686 members

Comments by Skippums (Top 4 by date)

Skippums 26-Jun-11 13:11pm View    
I spoke too soon when saying that your solution fixed the glitch. The packing between the two builds is now the same (both are 8), but I am still seeing two different sizes for both std::map and std::vector between my DLL and client. Since our project is due this Friday, I am going to modify my approach to export a bunch of static functions that wrap the class's member functions (since I am using the exported object as a singleton anyway). So, for example, my class has function:

class myClass {
bool IsFunction(const size_t) const;
};

So in the DLL interface file I will have:

myClass *foo;
__declspec(dllexport) IsFunction(const size_t val) {
return foo->IsFunction(val);
}

Perhaps this is the accepted way to do accomplish singleton access anyway, so I don't have to worry about issues like inconsistent objects between builds. However, it adds another level of indirection between the client and DLL, it's more work maintaining the interface (since functions are not magically exported as I create them in myClass), and the client has to load more pointers to objects (instead of loading the single I have to load each function I want to use individually). I am still curios as to why this behavior is occurring. If you have any ideas, I'm more than happy to hear them :).
Skippums 22-Jun-11 15:45pm View    
Yep... for some reason, when building the DLL in x64 mode, the default packing is on 16-byte boundries. Setting /Zp8 in the compiling options (VS 2008) made both packing options the same. Thanks a lot,

-Jeff
Skippums 21-Jun-11 13:17pm View    
Thank you for taking the time to answer my question. Explicitly specifying the calling convention is definitely something that needs to be done. However, I noticed that my current problem stems from the fact that sizeof(std::vector<mytype>) changes between the DLL (where it is 40 bytes) and the client (where it is 32 bytes). I modified my question to be more concise and to reflect this knowlege, but do you have any ideas as to why this would be different between two builds? Thanks,

-Jeff
Skippums 20-Jun-11 23:17pm View    
Deleted
Update:

I noticed the following:
sizeof(foo); // This is different between the DLL and client
sizeof(size_t); // This is the same between the DLL and client

Do I need to specify the packing of members? Why is this different between the DLL and client when they are both built for the x64 architecture? Thanks,

-Jeff