C ++ Visual Studio 2012问题

时间:2015-12-14 17:28:24

标签: c++ visual-studio-2012

更新了问题#3

我已经缩小了问题范围。似乎只包含<thread>会让编译器发疯。 我甚至没有进行任何线程调用,只包括它。

我尝试过启用/ EHsc并禁用它。

已停用,我明白了:

我收到这6条消息:

Error   1   error C2220: warning treated as error - no 'object' file generated (main.cpp)   C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 313 1   cefclient
Warning 2   warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (main.cpp)   C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 313 1   cefclient
Error   3   error C2220: warning treated as error - no 'object' file generated (Program.cpp)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 313 1   cefclient
Warning 4   warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (Program.cpp)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 313 1   cefclient
Error   5   error C3861: '__uncaught_exception': identifier not found (main.cpp)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 4774    1   cefclient
Error   6   error C3861: '__uncaught_exception': identifier not found (Program.cpp) C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 4774    1   cefclient

如果启用(配置属性 - &gt; C / C ++ - &gt;代码生成&amp;在命令行中)

Error   1   error C3861: '__uncaught_exception': identifier not found (main.cpp)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 4774    1   cefclient

Error   2   error C3861: '__uncaught_exception': identifier not found (Program.cpp) C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 4774    1   cefclient

我使用一个新的空白项目做了一个简单的测试,包括线程和只是编译。它很好,没有错误。 但是在我的主项目中,我使用的是Chromium Embedded Framework v3,它似乎与线程包含奇怪地交互?

奇怪的是,仅仅包括它就会造成这样的混乱。

有什么想法吗?

更新

通过完全删除_HAS_EXCEPTIONS = 0标志并从CMake重建项目,我进入一个项目甚至无法编译的状态。 由于这种变化,它会从各种文件中抛出大量的警告和错误。

错误如:

Warning 230 warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (C:\Users\mads\Desktop\cef_binary_3.2526.1347.gcf20046_windows32\cefclient\browser\client_handler_osr.cc)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale  337 1   cefclient

根据很多询问和谷歌搜索,解决方案是在项目属性中指定/ EHsc - &gt; C / C ++ - &gt;代码生成 - &gt;启用C ++异常=是(/ EHsc)。 以及在命令行输入字段中设置标志/ EHsc。

然而,没有任何改变。同样的错误就好像什么都没有改变一样。

更新

错误

Warning 2   warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc (C:\Users\mads\Desktop\cef_binary_3.2556.1368.g535c4fb_windows32\libcef_dll\transfer_util.cc)    C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xlocale  337 1   libcef_dll_wrapper

来自项目&#34; libcef_dll_wrapper&#34;尽管事实上我已经在项目设置中设置了/ EHsc!两者都在C ++中 - &gt;代码生成页面和命令行

解决方案编辑:

事实证明,每当我尝试构建或运行项目时,cmake文件都会覆盖我的设置设置,因此尽管已设置,但仍会呈现我未使用的任何更改! 我能够通过直接编辑项目的cmake文件来解决问题。 之前从未使用过cmake,所以最终它成为了一种学习体验。 我现在用线程包含测试了我的项目,它按预期编译!

感谢所有人提出的好建议

1 个答案:

答案 0 :(得分:1)

确保代码和编译器命令行都没有定义_HAS_EXCEPTIONS = 0。

Compiling VC++ 12.0 with _HAS_EXCEPTIONS=0 and including concrt.h causes a compiler error

  

如果使用VC ++ 12.0编译源文件且_HAS_EXCEPTIONS设置为0且源包括(无论是直接还是间接)concrt.h,编译器会给出错误:

     

C:\ Program Files(x86)\ Microsoft Visual Studio 12.0 \ VC \ INCLUDE \ concrt.h(4774):错误C3861:'__ command_exception':找不到标识符

     

[...]宏_HAS_EXCEPTIONS = 0未记录且不受Microsoft支持。   由于遗留原因,它可能与STL库的某些部分一起使用,但它与ConcRT库(concrt.h)不兼容,因为ConcRT依赖于取消的异常。