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

        • <bdo id='swa6u'></bdo><ul id='swa6u'></ul>

        使用#pragma warning push/pop 是暂时改变警告级别的正确方法吗?

        Is using #pragma warning push/pop the right way to temporarily alter warning level?(使用#pragma warning push/pop 是暂时改变警告级别的正确方法吗?)

      1. <small id='M7aJU'></small><noframes id='M7aJU'>

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

              <bdo id='M7aJU'></bdo><ul id='M7aJU'></ul>
              <tfoot id='M7aJU'></tfoot><legend id='M7aJU'><style id='M7aJU'><dir id='M7aJU'><q id='M7aJU'></q></dir></style></legend>

                  <tbody id='M7aJU'></tbody>
                • 本文介绍了使用#pragma warning push/pop 是暂时改变警告级别的正确方法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有时很难编写完全不发出警告的 C++ 代码.然而,启用警告是一个好主意.因此,通常需要禁用围绕某些特定构造的警告,并在所有其他代码段中启用它们.

                  Once in a while it's difficult to write C++ code that wouldn't emit warnings at all. Having warnings enabled is however a good idea. So it is often necessary to disable warnings around some specific construct and have them enables in all other pieces of code.

                  到目前为止,我已经看到了两种方法.

                  I've seen two ways of doing that so far.

                  第一个是使用#pragma warning( push )#pragma warning( pop ):

                   #pragma warning( push )
                   #pragma warning( disable: ThatWarning )
                   //code with ThatWarning here
                   #pragma warning( pop )
                  

                  第二种是使用#pragma warning(default):

                   #pragma warning( disable: ThatWarning )
                   //code with ThatWarning here
                   #pragma warning( default: ThatWarning )
                  

                  我在第二个变体中看到的问题是它丢弃了原始警告级别 - 警告可能在此之前已关闭,或者其警告级别可能已更改.使用 default 将丢弃这些更改.

                  The problem I see in the second variant is that it discards the original warning level - the warning might have been off before that or its warning level might have been altered. Using default would discard those alterations.

                  第一种方法看起来很干净.它有什么问题吗?有没有更好的方法来实现相同的目标?

                  The first approach looks clean. Are there any problems with it? Are there any better ways to achieve the same?

                  推荐答案

                  第一种方法是最好的方法,IMO.我知道它没有问题.

                  The first method is the best way to do it, IMO. I know of no problems with it.

                  请记住,#pragma 是特定于编译器的,所以不要指望它适用于所有编译器:)

                  Simply bear in mind that a #pragma is compiler specific so don't expect it to work on every compiler out there :)

                  这篇关于使用#pragma warning push/pop 是暂时改变警告级别的正确方法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  Consistent pseudo-random numbers across platforms(跨平台一致的伪随机数)
                  Vary range of uniform_int_distribution(改变uniform_int_distribution的范围)
                  What is a seed in terms of generating a random number?(就生成随机数而言,种子是什么?)
                  Is 1.0 a valid output from std::generate_canonical?(1.0 是 std::generate_canonical 的有效输出吗?)
                  Getting big random numbers in C/C++(在 C/C++ 中获取大随机数)
                  What is the best way to generate random numbers in C++?(在 C++ 中生成随机数的最佳方法是什么?)

                  • <small id='IrJ5R'></small><noframes id='IrJ5R'>

                  • <legend id='IrJ5R'><style id='IrJ5R'><dir id='IrJ5R'><q id='IrJ5R'></q></dir></style></legend>
                      <bdo id='IrJ5R'></bdo><ul id='IrJ5R'></ul>

                        <tbody id='IrJ5R'></tbody>

                        1. <tfoot id='IrJ5R'></tfoot>

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