Reputation: 81
When I try some features of c++17, I build my code in command line as follow:
llvm-g++ -std=c++17 main.cpp
but it failed. I got:
error: invalid value 'c++17' in '-std=c++17'
the version of my llvm-g++ is:
[wjy@wjy-mba] cpp$ llvm-g++ -v
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
and at the same time, I can build my code in Xcode (with c++17). Xcode setting
Upvotes: 7
Views: 6552
Reputation: 1022
Apple-LLVM 10 that comes with Xcode 10 supports C++17 and C++20 draft:
note: use 'c++98' or 'c++03' for 'ISO C++ 1998 with amendments' standard
note: use 'gnu++98' or 'gnu++03' for 'ISO C++ 1998 with amendments and GNU
extensions' standard
note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions'
standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions'
standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions'
standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions'
standard
Upvotes: 1
Reputation: 357
-std=c++17
was added in Clang 5.0.0 (released very recently - earlier this month - see http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html).
This page https://en.wikipedia.org/wiki/Xcode#Latest_versions appears to believe Xcode 9.0 is still using the LLVM/Clang 4.0 release. This is in agreement with the error you're running into.
Upvotes: 5