Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Class size change between application and exe

I have a console application that instantiates a class (say class X). The class is defined in a dll -> X.dll. When I print the size of class in the application and inside one of class's functions (which gets called when application invokes it) - I notice a size change.

I am using the VS 2010 and the application prints class size as 6304 and the function prints that as 6352. I have compiled both the exe and dll in Release|Win32 mode. Both have WIN32 and _WINDOWS defined. But do not have WIN64 defined.

What I noticed more is when I print sizeof(time_t) in the exe, it prints 4 and the function in dll prints 8. Think this could be a problem.

Any idea where I should check?

like image 625
Prabhu Avatar asked Dec 21 '22 03:12

Prabhu


1 Answers

I agree that it will likely be a problem if a DLL and an EXE disagree on the layout of data types.

However, I cannot see any other explanation besides that you must be using different project settings between the two projects.

In order to find the culprit, mark both projects in the solution (Ctrl+Left Click), then bring up the properties dialog. The dialog will now only display the properties that are the same for both projects in the selected configuration. Despite the dialog at a first glance seeming to be a modal one, you can click on one of the projects to see only its properties, and you can also again mark both of them, so you can switch back and forth between those views. So far, I have usually found the problem using this technique.

If this fails, you can always compare the project files. They being quite chatty XML files makes this harder, though.

like image 158
sbi Avatar answered Dec 24 '22 02:12

sbi