Reputation: 367
I noticed that std::uncaught_exceptions symbol is missing from the stock libc++ on my Mac:
$ clang++ -v; otool -L /usr/lib/libc++.dylib
Apple LLVM version 7.3.0 (clang-703.0.31)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
/usr/lib/libc++.dylib:
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 125.0.0)
...
$ nm /usr/lib/libc++.dylib | c++filt | grep uncaught
0000000000007782 T std::uncaught_exception()
U ___cxa_uncaught_exception
However, the header declares the prototype:
$ pwd
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1
$ grep uncaught_exceptions exception
int uncaught_exceptions() noexcept; // C++17
_LIBCPP_FUNC_VIS int uncaught_exceptions() _NOEXCEPT;
Is this a bad build or something? From the libc++ source I see that the symbol should end up in libc++ but it's not there and I get a missing symbol when linking.
Edit: here is a minimal failing program:
$ cat t.cpp; clang++ -std=c++1z t.cpp
#include <exception>
int main () {
return std::uncaught_exceptions ();
}
Undefined symbols for architecture x86_64:
"std::uncaught_exceptions()", referenced from:
_main in t-a4015f.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Upvotes: 1
Views: 1481
Reputation: 219205
It has been a while (couple years) since Apple thought it important enough to update libc++.dylib. I hear rumors it might be updated in the OS after El Capitan.
What's wrong with Swift?! ;-)
Upvotes: 2