类大小在应用程序和exe之间的变化 [英] Class size change between application and exe

查看:94
本文介绍了类大小在应用程序和exe之间的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制台应用程序实例化一个类(例如 class X )。该类在dll - > X.dll中定义。当我在应用程序和类的函数(当应用程序调用时调用)中打印类的大小 - 我注意到一个大小的变化。

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.

我使用的VS 2010和应用程序打印类大小为6304和函数打印为6352.我已经编译了exe和dll在版本| Win32模式。两者都定义了 WIN32 _WINDOWS 。但是没有定义 WIN64

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.

我注意到更多的是当我在exe中打印 sizeof(time_t)时,它打印4和函数在dll打印8.认为这可能是一个问题。

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?

推荐答案

如果DLL和EXE 在数据类型的布局上不同意 ,则可能会出现问题。

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.

为了找到罪魁祸首,在解决方案中 标记两个项目 Ctrl +左键单击),然后调出属性对话框。对话框现在将只显示所选配置中的两个项目的 属性 。尽管对话框乍一看似乎是一个模态,您可以点击其中一个项目,只看到其属性,你也可以再次标记他们,所以你可以 切换回来,这些视图之间的 。到目前为止,我通常发现使用这种技术的问题。

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.

如果失败,您可以随时 比较项目文件 。他们是相当聊天的XML文件,这使得这更困难,虽然。

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

这篇关于类大小在应用程序和exe之间的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆