How can I enable compiler warnings in Visual Studio 2019?

前端 未结 1 796
春和景丽
春和景丽 2021-01-29 10:31

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 mistake

1条回答
  •  囚心锁ツ
    2021-01-29 11:09

    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

    0 讨论(0)
提交回复
热议问题