Issue
I can't compile with -std=c++17, I got :
error: invalid value 'c++17' in '-std=c++17'
However I update Xcode and clang.
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-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin`
And I load the newest header like optional, I have to do
#include <experimental/optional>
instead of
#include <optional>
Solution
Xcode brings its own complete toolchain, including headers and the actual compiler.
Apple LLVM version 9.0.0 (clang-900.0.39.2)
(which ships with Xcode 9.2) does not support the usage of the flag -std=c++17
since its too old. The optional header is only included under the folder experimental/
. Which is why you need to #include <experimental/optional>
In order to compile your program with c++17 support using the compiler which comes with Xcode 9.2 you need to use the -std=c++1z
flag.
Xcode 9.3 will be shipped with Apple LLVM version 9.1.0 (clang-902.0.30)
which has support for the -std=c++17
flag. However the optional
header is as of today still under the experimental/
subdirectory. This might change during the betas.
Answered By - p0fi Answer Checked By - Clifford M. (WPSolving Volunteer)