将特定警告视为错误Xcode

rag*_*hul 4 xcode build-settings

在构建设置中,可以将特定警告视为错误,而不是将所有警告视为错误。

这是xcode中一个简单的Switch语句检查器:

GCC_WARN_CHECK_SWITCH_STATEMENTS = YES_Error 
Run Code Online (Sandbox Code Playgroud)

代替 :

GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 
Run Code Online (Sandbox Code Playgroud)

但是它对我不起作用。

lea*_*vez 5

将特定警告视为错误

使用 -Werror=

例如: -Werror=unused-variable将未使用的变量视为错误,最初将其视为-Wunused-variable标志警告

将它们添加到Other Warning Flags项目设置中。

除某些警告外,将所有警告视为错误

使用-Werror-Wno-error=

第一个将所有警告视为错误,等于Xcode中的设置。

-Wno-error=用来做出特定的警告不是错误。例如: -Wno-error=unused-variable

将它们添加到Other Warning Flags项目设置中。


参考https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

对于所有警告标记https://clang.llvm.org/docs/DiagnosticsReference.html


iCr*_*ive 0

此链接可能适合您。

http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

-Wno-error=switch 使 -Wswitch 警告不会成为错误,即使 -Werror 有效时也是如此。

请检查。