I installed Xcode 9.2 on a new MacBook Pro. Unfortunately it failed to compile my programs. The problem can be reproduced with a Hello World! C++ program.
// helloworld.cpp
#include <iostream>
int main()
{
std::cout<<"Hello World!\n";
return 0;
}
Running "$ g++ helloworld.cpp", the error starts from iostream as follows:
In file included from helloworld.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/iostream:40:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/istream:163:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/ostream:140:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/locale:2212:23: error: member access into incomplete
type 'tm'
__get_day(__tm->tm_mday, __b, __e, __err, __ct);
^
/usr/include/wchar.h:131:19: note: forward declaration of 'tm'
const struct tm * __restrict) __DARWIN_ALIAS(wcsftime);
I tried reinstalling Xcode, but the same error showed up. Has anyone seen this problem? Thanks!
And here's the g++ version.
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.39.2)
Target: x86_64-apple-darwin17.3.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin