treat specific warning as error Xcode

浪尽此生 提交于 2019-11-29 22:58:36

问题


In the Build Settings is it possible to treat Specific warnings as Error instead of Treating all warnings are Errors.

This is a simple Switch statement checker in xcode :

GCC_WARN_CHECK_SWITCH_STATEMENTS = YES_Error 

instead of :

GCC_WARN_CHECK_SWITCH_STATEMENTS = YES 

But its not working for me.


回答1:


Treat specific warnings as errors

use -Werror=

for example: -Werror=unused-variable will treat unused variable as error, which originally treat as warning by -Wunused-variable flag

add these to Other Warning Flags in project setting.

Treat all warnings as errors except for some warnings

use -Werror and -Wno-error=

The first one will treat all warnings as errors, equals to the setting in Xcode.

And use -Wno-error= to make specific warning not be error. For example: -Wno-error=unused-variable

add these to Other Warning Flags in project setting.


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

For all warning flags https://clang.llvm.org/docs/DiagnosticsReference.html




回答2:


This link may work for you.

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

-Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect.

Please check.



来源:https://stackoverflow.com/questions/24059623/treat-specific-warning-as-error-xcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!