apple llvm 9.0 can not use flag c++17

Viewed 6399

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

3 Answers

I believe you are looking for the flag -std=c++1z

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
Related