如何在Clang中获取支持的标准列表?

如何在Clang中获取支持的标准列表?,clang,Clang,我在男人身上发现了这一点: -std=language Specify the language standard to compile for. -ansi Same as -std=c89. 但是在哪里可以找到我安装的编译器支持的所有标准的列表呢 clang -std=??? test.c 检查此文件:llvm.git/tools/clang/include/clang/Frontend/LangStandards.def 编译器支持的标准不断

我在男人身上发现了这一点:

   -std=language
       Specify the language standard to compile for.

   -ansi
       Same as -std=c89.
但是在哪里可以找到我安装的编译器支持的所有标准的列表呢

clang -std=??? test.c

检查此文件:llvm.git/tools/clang/include/clang/Frontend/LangStandards.def

编译器支持的标准不断变化,您可以检查此文件并自己尝试

// C++ modes
LANGSTANDARD(cxx98, "c++98",
             "ISO C++ 1998 with amendments",
             LineComment | CPlusPlus | Digraphs)
LANGSTANDARD(cxx03, "c++03",
             "ISO C++ 1998 with amendments",
             LineComment | CPlusPlus | Digraphs)
LANGSTANDARD(gnucxx98, "gnu++98",
             "ISO C++ 1998 with amendments and GNU extensions",
             LineComment | CPlusPlus | Digraphs | GNUMode)

LANGSTANDARD(cxx0x, "c++0x",
             "ISO C++ 2011 with amendments",
             LineComment | CPlusPlus | CPlusPlus11 | Digraphs)
LANGSTANDARD(cxx11, "c++11",
             "ISO C++ 2011 with amendments",
             LineComment | CPlusPlus | CPlusPlus11 | Digraphs)
LANGSTANDARD(gnucxx0x, "gnu++0x",
             "ISO C++ 2011 with amendments and GNU extensions",
             LineComment | CPlusPlus | CPlusPlus11 | Digraphs | GNUMode)
LANGSTANDARD(gnucxx11, "gnu++11",
             "ISO C++ 2011 with amendments and GNU extensions",
             LineComment | CPlusPlus | CPlusPlus11 | Digraphs | GNUMode)

如果用户没有为-std选项提供有效的标准名称, 将报告可用值(简短描述)


只需指定任何BS标准,clang将打印可接受的标准,如下所示:

c:\LLVM\bin>clang++.exe -std=blabla main.cpp
error: invalid value 'blabla' in '-std=blabla'
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

;-)

touch dummy.cpp;clang-std=dummy dummy.cpp
对于lazy OneSprint,在Apple LLVM 9.0.0版(clang-900.0.39.2)上会显示错误,但不会显示建议注释。Centos 7上的clang++3.4.2也会显示错误,但不会显示建议。链接已失效。