如何在 Visual Studio 2019 中启用编译器警告? [英] How can I enable compiler warnings in Visual Studio 2019?
问题描述
我问这个问题的原因是以下链接:
我建议您可以尝试使用以下方法来启用默认关闭的警告:
1,#pragma 警告(默认:warning_number)指定的警告 (warning_number) 在其默认级别启用.警告文档包含警告的默认级别.
2,#pragma warning( warning_level : warning_number )指定的警告(warning_number)在指定的级别(warning_level)启用.
3,/墙/Wall 启用默认情况下关闭的所有警告.如果使用此选项,则可以使用/wd 选项关闭个别警告.
4,/wLnnnn此选项启用 L 级警告 nnnn.
有关警告级别的更多详细信息,我建议您可以参考以下链接:https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=vs-2019一个>
The reason that I ask this question is this link below: Why can this function return a C++ int reference?
It seems that the compiler is bad at reporting mistakes such as: return
a value from a function.
So I want to activate them in Visual Studio 2019, but it did not work after I set it (restart IDE) like below:
I suggest you could try to use the following method to enable warnings that are off by default:
1,#pragma warning(default : warning_number ) The specified warning (warning_number) is enabled at its default level. Documentation for the warning contains the default level of the warning.
2,#pragma warning( warning_level : warning_number ) The specified warning (warning_number) is enabled at the specified level (warning_level).
3,/Wall /Wall enables all warnings that are off by default. If you use this option, you can turn off individual warnings by using the /wd option.
4,/wLnnnn This option enables warning nnnn at level L.
For more details anbout warning level, I suggest you could refer to the link:https://docs.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=vs-2019
这篇关于如何在 Visual Studio 2019 中启用编译器警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!