I am working on a cpp code to port one application from Windows to Mac. While building the application in Xcode it throws the error saying:
"Use of undeclared identifier 'nothrow'; did you mean 'throw'? memory"
These errors are thrown in cpp standard library headers.
Below is the error stack description:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/memory:83:8: Use of undeclared identifier 'nothrow'; did you mean 'throw'?
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/string:48:10: In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/c++/4.2.1/string:48:
I searched in internet but was unable to find the solution for this problem. Any suggestions will be helpful. Why the error is thrown from the system header files?
System Details:
SDK is OSX 10.10.
Compiler option used to compile the application is C++ Standard Library:
libc++(LLVM C++ Standard with C++11 support. C++ Language Dialect: GNU++11. Compiler for C++ : Apple LLVM 6.0
A throw() specification on functions was deprecated in the '11 standard, and removed in the '17 standard. If clang does not support it, my guess is that that was an intentional choice on the developers' part, or you are compiling in c++17 mode.
The proper thing to do in modern c++ is to use a noexcept specification.
noexceptallows for more efficient code generation, in that it does not have to perform RTTI on thrown exceptions, instead if an exception is thrown from a call-frame underneath a noexcept-declared function, std::terminate is called, short-circuiting the crazy std::unexpected() machinery specified by the '98 standard.