MSVC ++警告标志 [英] MSVC++ warning flags

查看:58
本文介绍了MSVC ++警告标志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于 gcc clang ,我通常使用 -Wall -Wextra 警告标志.

With gcc and clang, I routinely use -Wall -Wextra warning flags.

Visual C ++ 2010中使用哪些命令行开关(如果存在差异,则更新版本)会产生大致相同的结果?

What command line switches for Visual C++ 2010 (and newer, if there are differences) would produce about same result?

此MSDN文档页面提供了技术细节,但是根据实际经验,我得到了Visual C ++开发人员的更定性的回答:经验法则"标志可以使您在启动新项目时安全地抛出任何新项目,仍然可以捕捉到几乎相同的东西其他编译器捕获的 -Wall -Wextra .

This MSDN document page provides the technical details, but I am after a more qualitative answer from Visual C++ developers, based on practical experience: A "rule of thumb" flags you can safely throw on any new project when you start, that would still catch approximately the same things that -Wall -Wextra of the other compilers catch.

推荐答案

我同意@Paulius的回答

I agree with @Paulius's answer here which you linked to in the comments. /W4 will show you all warnings that are not disabled by default, which is probably the closest you can get to "approximately the same things" without searching through each of the warnings individually and enabling the equivalent. /Wall in MSVC will do what it says and turn on all warnings (even the questionable ones), which for any non-trivial project will give false positives. This is different from gcc -Wall, which will only turn on warnings that are not "questionable".

这篇关于MSVC ++警告标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆