Why do compiler gives error instead of warning for variable which is assigned but its value is never used

Viewed 1374

I know there are lot of question which is asked previously about

The variable which is assigned but its value is never used

Here,Here and Here

I am getting compile time Error instead of warning which causes compile or rebuild to fail. i didn't update my Visual studio 2015 nor do i installed any VS extension

so my question is what can i do so Visual studio show warning instead of Compile time Error.

enter image description here

2 Answers

In the project-properties is a setting "Treat warnings as errors" which you apparently switched on.

project-properties

To undo: Project->Properties->Build->Treat warnings as errors->None
(None is the default-setting for new projects.)

Read this for reference.

Note:
It's certainly still a good idea to set this setting to All, to ensure the code is error- and "garbage"-free.

To treat all compiler warnings as compilation errors:

  1. With a project selected in Solution Explorer, on the Project menu, click Properties.
  2. Click the Compile tab.
  3. Select the Treat all warnings as errors check box. (or select the build setting and change the “treat warnings as errors” settings to TRUE)

To disable all compiler warnings

  1. With a project selected in Solution Explorer, on the Project menu click Properties.
  2. Click the Compile tab.
  3. Select the Disable all warnings check box. (or select the build setting and change the “treat warnings as errors” settings to FALSE.)
Related