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

    2. <tfoot id='tNfPJ'></tfoot>

        <i id='tNfPJ'><tr id='tNfPJ'><dt id='tNfPJ'><q id='tNfPJ'><span id='tNfPJ'><b id='tNfPJ'><form id='tNfPJ'><ins id='tNfPJ'></ins><ul id='tNfPJ'></ul><sub id='tNfPJ'></sub></form><legend id='tNfPJ'></legend><bdo id='tNfPJ'><pre id='tNfPJ'><center id='tNfPJ'></center></pre></bdo></b><th id='tNfPJ'></th></span></q></dt></tr></i><div id='tNfPJ'><tfoot id='tNfPJ'></tfoot><dl id='tNfPJ'><fieldset id='tNfPJ'></fieldset></dl></div>
          <bdo id='tNfPJ'></bdo><ul id='tNfPJ'></ul>
      1. C/C++:如何使用 do-while(0);没有像 C4127 这样的编译

        时间:2023-10-05

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

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

            • <i id='UPcxZ'><tr id='UPcxZ'><dt id='UPcxZ'><q id='UPcxZ'><span id='UPcxZ'><b id='UPcxZ'><form id='UPcxZ'><ins id='UPcxZ'></ins><ul id='UPcxZ'></ul><sub id='UPcxZ'></sub></form><legend id='UPcxZ'></legend><bdo id='UPcxZ'><pre id='UPcxZ'><center id='UPcxZ'></center></pre></bdo></b><th id='UPcxZ'></th></span></q></dt></tr></i><div id='UPcxZ'><tfoot id='UPcxZ'></tfoot><dl id='UPcxZ'><fieldset id='UPcxZ'></fieldset></dl></div>
              <legend id='UPcxZ'><style id='UPcxZ'><dir id='UPcxZ'><q id='UPcxZ'></q></dir></style></legend>
              • <bdo id='UPcxZ'></bdo><ul id='UPcxZ'></ul>
                1. 本文介绍了C/C++:如何使用 do-while(0);没有像 C4127 这样的编译器警告的构造?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我经常在我的#defines 中使用 do-while(0) 构造,原因如下 在这个答案中.此外,我试图使用来自编译器的尽可能高的警告级别来捕获更多潜在问题并使我的代码更加健壮和跨平台.所以我通常将 -Wall 与 gcc 和 /Wall 与 MSVC 一起使用.

                  I'm often use do-while(0) construct in my #defines, for the reasons described in this answer. Also I'm trying to use as high as possible warning level from compiler to catch more potential problem and make my code more robust and cross-platform. So I'm typically using -Wall with gcc and /Wall with MSVC.

                  不幸的是 MSVC 抱怨 do-while(0) 构造:

                  Unfortunately MSVC complain about do-while(0) construct:

                  foo.c(36) : warning C4127: conditional expression is constant
                  

                  我应该怎么处理这个警告?

                  What should I do about this warning?

                  只是对所有文件全局禁用它?这对我来说似乎不是个好主意.

                  Just disable it globally for all files? It does not seems to be good idea for me.

                  推荐答案

                  总结:在这种特殊情况下的这个警告 (C4127) 是一个微妙的编译器错误.随意禁用它.

                  Summary: This warning (C4127) in this particular case is a subtle compiler bug. Feel free to disable it.

                  深入:

                  它旨在捕捉逻辑表达式在不明显的情况下计算为常量的情况(例如,if(a==a && a!=a),以及以某种方式,它将 while(true) 和其他有用的构造变成无效的.

                  It was meant to catch situations when logical expression evaluates to a constant in non-obvious situations (such as, if(a==a && a!=a), and somehow, it turned while(true) and other useful constructs into invalid.

                  如果您想打开此警告,Microsoft 建议使用 for(;;) 进行无限循环,并且没有针对您的情况的解决方案.这是我公司的开发约定允许禁用的极少数 4 级警告之一.

                  Microsoft recommends using for(;;) for infinite loop if you want to have this warning on, and there is no solution for your case. This is one of very few Level-4 warnings my company's development conventions allow to disable.

                  这篇关于C/C++:如何使用 do-while(0);没有像 C4127 这样的编译器警告的构造?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:信号 NaN 的用处? 下一篇:如何使用 MFC 加载 .png 、 .jpeg 图像?

                  相关文章

                  最新文章

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

                        <bdo id='5Slsl'></bdo><ul id='5Slsl'></ul>