I believe this issue is related to Broken c++ std libraries on macOS High Sierra 10.13, however, the fixes there did not help -- so this could be a different type of issue.
The issue
This is the code I am using to test compile; I can reproduce the issue with any C++ file, however.
#include <iostream>
#include <iterator>
#include <algorithm>
int main() {
std::copy(std::istream_iterator<char>{std::cin}, {}, std::ostream_iterator<char>{std::cout, ""});
return 0;
}
This produces this error:
clang++ -std=c++11 test.cpp
In file included from test.cpp:1:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:38:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ios:216:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__locale:15:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:470:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:169:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:643:
In file included from /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/memory:650:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iterator:432:10: fatal error: 'Availability.h' file not found
#include <Availability.h>
^~~~~~~~~~~~~~~~
Now, I'm not sure why that header would be missing. Either way, I downloaded old versions of the headers off the internet, and tried that. This actually compiled my test file, but lead to errors in other files, leading me to believe that my toolchain was broken. I then completely reinstalled both the stable and beta versions of Xcode, got the exact same issue.
The other error I get is this:
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/math.h:1272:93: error: no member named 'llrintf' in the global namespace
inline _LIBCPP_INLINE_VISIBILITY long long llrint(float __lcpp_x) _NOEXCEPT {return ::llrintf(__lcpp_x);}
Which I have noticed to be exactly the same as this ancient one https://gist.github.com/pjmartorell/4165805. That gist does not have a fix.
Steps I've tried
- Switching to the stable toolchain
- Reinstalling Xcode
- Rebooting
- Downloading the missing headers manually
xcode-select --install
This is my first issue on SO, apologies if this is in the wrong place, or if I haven't gone into enough detail. This is just driving me insane at this point.