<i id='oKJ86'><tr id='oKJ86'><dt id='oKJ86'><q id='oKJ86'><span id='oKJ86'><b id='oKJ86'><form id='oKJ86'><ins id='oKJ86'></ins><ul id='oKJ86'></ul><sub id='oKJ86'></sub></form><legend id='oKJ86'></legend><bdo id='oKJ86'><pre id='oKJ86'><center id='oKJ86'></center></pre></bdo></b><th id='oKJ86'></th></span></q></dt></tr></i><div id='oKJ86'><tfoot id='oKJ86'></tfoot><dl id='oKJ86'><fieldset id='oKJ86'></fieldset></dl></div>

      <legend id='oKJ86'><style id='oKJ86'><dir id='oKJ86'><q id='oKJ86'></q></dir></style></legend>
    1. <small id='oKJ86'></small><noframes id='oKJ86'>

      1. <tfoot id='oKJ86'></tfoot>
        • <bdo id='oKJ86'></bdo><ul id='oKJ86'></ul>

        如何在 -std=c++11 -Weverything -Werror 中使用 clang++

        How to use clang++ with -std=c++11 -Weverything -Werror(如何在 -std=c++11 -Weverything -Werror 中使用 clang++)
            <bdo id='DrlP0'></bdo><ul id='DrlP0'></ul>
              1. <tfoot id='DrlP0'></tfoot>
              2. <legend id='DrlP0'><style id='DrlP0'><dir id='DrlP0'><q id='DrlP0'></q></dir></style></legend>

                <i id='DrlP0'><tr id='DrlP0'><dt id='DrlP0'><q id='DrlP0'><span id='DrlP0'><b id='DrlP0'><form id='DrlP0'><ins id='DrlP0'></ins><ul id='DrlP0'></ul><sub id='DrlP0'></sub></form><legend id='DrlP0'></legend><bdo id='DrlP0'><pre id='DrlP0'><center id='DrlP0'></center></pre></bdo></b><th id='DrlP0'></th></span></q></dt></tr></i><div id='DrlP0'><tfoot id='DrlP0'></tfoot><dl id='DrlP0'><fieldset id='DrlP0'></fieldset></dl></div>
                    <tbody id='DrlP0'></tbody>

                  <small id='DrlP0'></small><noframes id='DrlP0'>

                  本文介绍了如何在 -std=c++11 -Weverything -Werror 中使用 clang++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想编译以下文件(temp.cpp):

                  I want to compile the following file (temp.cpp):

                  #include <iostream> 
                  
                  class Foo {
                  public:
                    Foo() = default;
                  };
                  
                  int main(){
                    std::cout << "Works!" << std::endl;
                    return 0;
                  }
                  

                  使用以下命令:clang++ temp.cpp -o temp -std=c++11 -Weverything -Werror

                  有一个错误:

                  temp.cpp:5:11: 错误:默认函数定义与 C++98 不兼容 [-Werror,-Wc++98-compat]

                  temp.cpp:5:11: error: defaulted function definitions are incompatible with C++98 [-Werror,-Wc++98-compat]

                  我知道有一个像 c++98-compat 这样的警告,它是一切的一部分.如何启用除 c++98-compat 之外的所有警告?-Weverything 是否有 C++11 兼容标志?

                  I understand that there is a warning like c++98-compat and it is part of everything. How can I enable all warnings except c++98-compat? Is there a c++11 compatible flag for -Weverything?

                  推荐答案

                  实际上,您可能不想要所有的警告,因为许多警告可以被认为是风格或主观的和其他的(例如您运行的警告)犯规)在你的情况下只是愚蠢的.

                  Actually, you probably do not want all the warnings, because a number of warnings can be considered as being stylistic or subjective and others (such as the one you ran afoul of) are just stupid in your situation.

                  -Weverything 最初的构建有两个原因:

                  -Weverything was initially built for two reasons:

                  • 发现:否则很难获得所有可用警告的列表
                  • 黑名单替代方案:使用 gcc,您可以挑选您希望应用的警告(白名单),使用 -Weverything 您可以挑选您不想应用的警告;优点是当迁移到新版本的编译器时,您更有可能从新警告中受益
                  • discovery: it's pretty hard otherwise to get a list of all available warnings
                  • black-listing alternative: with gcc, you cherry pick the warnings you wish to apply (white-listing), with -Weverything you cherry pick those you do not wish to apply; the advantage is that when moving over to a new version of the compiler, you are more likely to benefit from new warnings

                  显然,发现与生产使用并不真正兼容;因此,您似乎属于列入黑名单的情况.

                  Obviously, discovery is not really compatible with production use; therefore you seem to fall in the black-listing case.

                  Clang 诊断系统将输出(默认情况下)负责生成警告的最具体警告组的名称(此处为 -Wc++98-compat)并且每个警告组可以是通过在 -W 之后添加 no- 来关闭.

                  Clang diagnostics system will output (by default) the name of the most specific warning group that is responsible for generating a warning (here -Wc++98-compat) and each warning group can be turned off by adding no- right after the -W.

                  因此,对于列入黑名单,您将获得:

                  Therefore, for blacklisting, you get:

                  -Weverything -Wno-c++98-compat -Wno-...
                  

                  我们鼓励您不时修改列入黑名单的警告列表(例如,当您升级到更新的编译器时).

                  And you are encouraged to revise the list of blacklisted warnings from time to time (for example, when you upgrade to a newer compiler).

                  这篇关于如何在 -std=c++11 -Weverything -Werror 中使用 clang++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is Type(::x); valid?(是类型(::x);有效的?)
                  Difference between an inline function and static inline function(内联函数和静态内联函数的区别)
                  Compilation fails randomly: quot;cannot open program databasequot;(编译随机失败:“无法打开程序数据库)
                  Too many initializers error for a simple array in bcc32(bcc32 中的简单数组的初始值设定项过多错误)
                  No Member named stoi in namespace std(命名空间 std 中没有名为 stoi 的成员)
                  Error using a constexpr as a template parameter within the same class(在同一个类中使用 constexpr 作为模板参数时出错)

                    <i id='Mij1t'><tr id='Mij1t'><dt id='Mij1t'><q id='Mij1t'><span id='Mij1t'><b id='Mij1t'><form id='Mij1t'><ins id='Mij1t'></ins><ul id='Mij1t'></ul><sub id='Mij1t'></sub></form><legend id='Mij1t'></legend><bdo id='Mij1t'><pre id='Mij1t'><center id='Mij1t'></center></pre></bdo></b><th id='Mij1t'></th></span></q></dt></tr></i><div id='Mij1t'><tfoot id='Mij1t'></tfoot><dl id='Mij1t'><fieldset id='Mij1t'></fieldset></dl></div>
                    <legend id='Mij1t'><style id='Mij1t'><dir id='Mij1t'><q id='Mij1t'></q></dir></style></legend>
                  • <small id='Mij1t'></small><noframes id='Mij1t'>

                      <tbody id='Mij1t'></tbody>
                    <tfoot id='Mij1t'></tfoot>

                        <bdo id='Mij1t'></bdo><ul id='Mij1t'></ul>