更新問題#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