How to use clang++ with -std=c++11 -Weverything -Werror

孤街醉人 提交于 2019-11-28 07:34:40

Actually, you probably do not want all the warnings, because a number of warnings can be considered as being stylistic or subjective and others (such as the one you ran afoul of) are just stupid in your situation.

-Weverything was initially built for two reasons:

  • discovery: it's pretty hard otherwise to get a list of all available warnings
  • black-listing alternative: with gcc, you cherry pick the warnings you wish to apply (white-listing), with -Weverything you cherry pick those you do not wish to apply; the advantage is that when moving over to a new version of the compiler, you are more likely to benefit from new warnings

Obviously, discovery is not really compatible with production use; therefore you seem to fall in the black-listing case.

Clang diagnostics system will output (by default) the name of the most specific warning group that is responsible for generating a warning (here -Wc++98-compat) and each warning group can be turned off by adding no- right after the -W.

Therefore, for blacklisting, you get:

-Weverything -Wno-c++98-compat -Wno-...

And you are encouraged to revise the list of blacklisted warnings from time to time (for example, when you upgrade to a newer compiler).

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