compile issue with "_HAS_EXCEPTIONS=0"

Jan 20, 2016 at 6:29 PM
my project has "/D _HAS_EXCEPTIONS=0" defined for some reasons, then I got the following compile error
Error 4 error C3861: '__uncaught_exception': identifier not found C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\concrt.h 4774 1 SkyLib

I want to know whether there is a way to make C++ REST SDK work with "/D _HAS_EXCEPTIONS=0
Coordinator
Jan 21, 2016 at 7:32 PM
It's unlikely to work. Such a scenario should be considered completely unsupported.

First of all, we use exceptions throughout the C++ REST SDK. Usually if you've defined _HAS_EXCEPTIONS=0 you will also disable exceptions at the command line. Because we communicate virtually all failures through exceptions, your application will be completely unable to recover from even trivial errors, such as the network being temporarily unavailable (and more).

If that is somehow acceptable, you could use the CPPREST_FORCE_PPLX macro to force the use of our internal copy of PPL tasks which should resolve the error above. This might reveal further issues, but you could modify the internal copy to fix those.

If you want to use the C++ REST SDK in an application that otherwise disables exceptions, I recommend splitting off all usage of the C++ REST SDK into a separate DLL that does not use _HAS_EXCEPTIONS=0 and is compiled with full C++ runtime support. You will likely need to avoid use of the STL on the DLL boundary, since the STL under _HAS_EXCEPTIONS=0 isn't guaranteed to have the same ABI as without the flag. This is a complicated scenario, but is much more likely to work "acceptably" than the above method.