错误 C1854:无法覆盖在目标文件中创建预编译头期间形成的信息

发布于 2024-07-24 06:48:37 字数 470 浏览 6 评论 0原文

foo.cpp(33918) : fatal error C1854: cannot overwrite information formed 
during creation of the precompiled header in object file: 'c:\somepath\foo.obj'

咨询MSDN这件事给了我以下信息:

您指定了 /Yu(使用预编译 header) 指定后的选项 /Yc(创建预编译头)选项 对于同一个文件。 肯定 声明(例如声明 包括 __declspec dllexport) make 这无效。

在本例中,我们使用 dllexport 和预编译头。 有人以前遇到过这种情况并知道任何解决方法吗? 非常感谢任何能够阐明这个问题的意见。

谢谢

foo.cpp(33918) : fatal error C1854: cannot overwrite information formed 
during creation of the precompiled header in object file: 'c:\somepath\foo.obj'

Consulting MSDN about this gives me the following information:

You specified the /Yu (use precompiled
header) option after specifying the
/Yc (create precompiled header) option
for the same file. Certain
declarations (such as declarations
including __declspec dllexport) make
this invalid.

We are using dllexport and precompiled headers in this case. Have anyone encountered this before and know of any workaround? Any input to shed some light on this problem is greatly appreciated.

Thanks

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

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

发布评论

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

评论(3

自找没趣 2024-07-31 06:48:37

我想你可以在这里找到答案: http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/b3aa10fa-141b-4a03-934c-7e463f92b2a5/

基本上,您需要设置stdafx.cpp文件到“创建预编译头”,所有其他 .cpp 文件到“使用预编译头”

I think you can find the answer here: http://social.msdn.microsoft.com/forums/en-US/vclanguage/thread/b3aa10fa-141b-4a03-934c-7e463f92b2a5/

Basically, you need to set the stdafx.cpp file to "Create Precompiled Headers" and all the other .cpp files to "Use Precompiled Headers"

孤凫 2024-07-31 06:48:37

我也有这个问题。

确保预编译器头输出文件设置到正确的位置。 我的实际上输出到了正确的位置,但是读取它时出现问题,因为路径内部有一些伪影。

I had this problem too.

Make sure the precompiler header output file is set to the correct location. Mine was actually outputted to the right location, but there were problems reading it just because the path had a little artifact inside.

何时共饮酒 2024-07-31 06:48:37

我的解决方案是仔细重新检查 .exe 项目中的所有预编译头设置,以及所有 dll 项目中的所有预编译头设置,并重新创建所有头。 之后 .exe 编译中的错误就消失了。

My solution was to carefully recheck all the precompiled header settings in not just the .exe project but all the dll projects also and recreate all the headers. After that the error was gone in the .exe compilation.

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