cl.exe 当 /E 输出相同且标志相同时目标文件中的差异

发布于 2024-07-24 07:51:31 字数 481 浏览 3 评论 0原文

我正在使用 Visual Studio 2005 的 cl.exe 编译器。 我用一堆 /I /D 和一些编译/优化标志来调用它(例如:/Ehsc)。

我有两个编译脚本,两者仅在 /I 标志方面有所不同(包含目录不同)。 所有其他标志都相同。 这些脚本生成不同的目标文件(而不仅仅是如下所述的时间戳差异)。 奇怪的是,两个脚本的 /E 输出是相同的。 这意味着包含文件不会导致目标文件中的差异,但话又说回来,差异从何而来?

谁能解释一下我在我的情况下如何看到两个不同的目标文件。 如果包含文件导致差异,我为什么会看到相同的 /E 输出?

附言。 目标文件不仅在时间戳上不同,而且在代码部分上也不同。 事实上,我的最终可执行文件的行为在这两种情况下都是不同的。

编辑:PSS:我什至查看了 cl.exe 的 /includeFiles 输出,该输出是相同的。 然而,目标文件的不同之处不仅仅是时间戳(事实上,一个比另一个大 1KB!)

I am using Visual Studio 2005's cl.exe compiler. I call it with a bunch of /I /D and some compilation/optimization flags (example: /Ehsc).

I have two compilation scripts, and both differ only in the /I flags (include directories are different). All other flags are the same. These scripts produce different object files (and not just a timestamp difference as noted below). The strange thing is that the /E output of both scripts is the same. That means that the include files are not causing the difference in object files, but then again, where is the difference coming from?

Can anyone elucidate on how I am seeing two different object files in my situation. If the include files are causing the difference, how come I see identical /E output?

PS. The object files are different not only in the timestamp, but in the code sections also. In fact the behavior of my final executable is different in both cases.

Edit: PSS: I even looked at the /includeFiles output of cl.exe and that output is identical. The object files, however, differ in more than just the timestamp (in fact, one is 1KB bigger than another!)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一身骄傲 2024-07-31 07:51:31

我的猜测是,您包含了 #define 一些您的代码所依赖的预处理器常量的头文件。 您已经提到您的可执行文件的行为是不同的。 如果您有不同的代码,那么目标文件的大小当然可能会有所不同。

如果是这样的话,/E 不应该吗?
输出不同? /E 标志给出
预处理器的输出。

好点子! 因此,如果您使用 /P (与 /E 相同,但用于文件),生成的文件完全相同吗?

My guess is that you are including header files which #define some preprocessor constants that your code in turn depends on. You already mentioned that the behavior of your executable is different. If you have different code, then of course the object files might differ in size.

If that is the case, shouldn't the /E
output be different? /E flag gives the
output of the preprocessor.

Good point! So if you use /P (same as /E but to file), the generated files are exactly identical?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文