简体   繁体   English

禁止编译器警告C ++

[英]Suppressing Compiler Warning C++

I'm getting a compile-time error. 我遇到了编译时错误。 It complains that I'm initializing a variable, but not referencing it. 它抱怨我正在初始化一个变量,但没有引用它。 What's happening is that I initialize it then make a debug print statement that only get's compiled in for a debug build but not a release build. 发生的事情是,我对其进行了初始化,然后创建了一条调试打印语句,该语句仅在调试版本中被编译,而在发行版本中未进行编译。 The error in question is warning c4189 (it's treated as an error and won't compile). 有问题的错误是警告c4189(将其视为错误并且不会编译)。

Is it possible to suppress this warning? 是否可以抑制此警告? How about warnings in general? 一般而言,警告如何?

Don't suppress the warning, fix it! 不要抑制警告,请解决它! Wrap the declaration and initialization of the variable so it only exists in a debug build too. 包装变量的声明和初始化,以便它也仅存在于调试版本中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM