更新问题#3C++的Visual Studio 2012个问题
我已经缩小的问题。似乎只是包括<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
,如果允许(配置属性 - > C/C++ - >代码生成&在命令行)
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标志和重建从C进行的项目,我进入的状态下该项目将不会编译。 由于这种改变,它会从各种文件中抛出大量的警告和错误。
错误如:
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 - > C/C++ - >代码生成 - >启用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
来自工程 “libcef_dll_wrapper”,尽管事实上,我有speficied/EHSC在其项目设置!无论是在C++ - >代码生成页面和命令行
解决方案编辑:
原来,cmake的文件将每次重写我的设置设置我试图建立或运行项目,从而使任何改变我尽管被设置,但仍未使用! 我能够通过直接编辑项目的cmake文件来解决问题。 以前从未使用cmake,所以最终它成为一种学习体验。 我已经使用线程包含测试了我的项目,并按预期编译!
感谢所有伟大的建议
5年来,需要使用线程绝不要求使用boost。 C++ 11具有完美的线程支持。 – SergeyA
@SergeyA谢谢你让我知道!我一直在做C#,但决定回到C++进行研究。我清理了我的项目,以便它不再包含提升,但错误仍然存在。我已经将代码退化为出现此错误之前的状态,好像我的项目设置/编译器被破坏了?大声笑 –
“我没有做任何更改,使这个错误出现” - 手动,或通过源代码管理?如果您还没有使用源代码管理,那么您设法解决此问题的第二个时间就是开始的时间,以便下次您可以可靠地撤消更改并确保没有任何内容持续存在。 – hvd