3

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

tabby
  • 1,878
  • 1
  • 21
  • 39

2 Answers2

11

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.

MatSnow
  • 7,357
  • 3
  • 19
  • 31
  • Comment: why to undo? Please add a humble hint to fix the code, not to silence the compiler. – Sourav Ghosh Oct 06 '17 at 06:59
  • 2
    @SouravGhosh Why should i? The question is about what to do to show a warning instead of an error. Not how to fix the code. – MatSnow Oct 06 '17 at 07:03
  • And which is a bad practice. Remember, this question and answer is not only for the OP but visible to all. Thats the actual scope of any info here. – Sourav Ghosh Oct 06 '17 at 07:07
  • @SouravGhosh This is your opinion. The default-setting is `None`. From this i conclude that MS considers this not as "bad practice". I would rather say, it is a bad practice to publish software with compiler warnings. But i will add a hint in my answer later. – MatSnow Oct 06 '17 at 07:22
0

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.)
Bungysheep
  • 40
  • 7