简体   繁体   中英

C++ Visual Studio 2012 issues

Updated problem #3

I've narrowed the problem. It seems that simply including <thread> makes the compiler go mad. I am not even making any thread calls, just including it.

I have tried enabling /EHsc and also disabling it.

Disabled, I get:

I get these 6 messages:

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

And if enabled (Configuration Properties -> C/C++ -> Code Generation & in the Command Line)

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

I did a simple test with a new, blank project, including thread and just compiling. It went fine, no errors. However in my main project I am using Chromium Embedded Framework v3, which seems to interact strangely with the thread inclusion?

Seems odd that simply including it would make such a mess.

Any ideas?

Update:

By removing the _HAS_EXCEPTIONS=0 flag entirely and rebuilding the project from CMake, I enter a state where the project won't even compile. Due to this change it throws out a ton of warnings and errors from various files.

Errors such as:

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

According to a lot of asking around and googling, the solution to this is to specify /EHsc in Project Properties -> C/C++ -> Code Generation -> Enable C++ Exceptions = Yes(/EHsc). As well as setting the flag /EHsc in the Command Line input field.

However, nothing changes. The same errors come out as if nothing was changed.

Update:

The error

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

comes from the project "libcef_dll_wrapper", despite the fact that I HAVE speficied /EHsc in its project settings! Both in C++ -> Code Generation page and the Command Line

Solution edit:

Turns out that cmake files would override my set settings everytime I attempted to build or run the project, hence rendering any changes I made un-used, despite being set! I was able to solve the problem by editing the project's cmake files directly. Never used cmake before, so in the end it became a learning experience. I have tested my project with thread inclusion now and it compiles as expected!

Thanks to all for great suggestions

Make sure neither the code nor the compiler command line define _HAS_EXCEPTIONS=0.

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

If a source file is compiled with VC++ 12.0 with _HAS_EXCEPTIONS set to 0 and the source includes, whether directly or indirectly, concrt.h, the compiler gives an error of:

C:\\Program Files (x86)\\Microsoft Visual Studio 12.0\\VC\\INCLUDE\\concrt.h(4774) : error C3861: '__uncaught_exception': identifier not found

[...] Macro _HAS_EXCEPTIONS=0 is undocumented and unsupported by Microsoft. It may work with some parts of the STL library for legacy reasons, but it won't be compatible with ConcRT library (concrt.h) since ConcRT depends on exceptions for cancellation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM