locked
Warning level 0 still generates warnings RRS feed

  • Question

  • I am using MS Visual Studio 2008 Pro (version 9.0.30729.1).  I would like to disable all compiler warnings for one project within my solution.  I attempted this by:

    - right clicking the project in Solution Explorer

    - selecting Properties

    - go to Build tab

    - change Warning Level to 0

    But it still generates all the same warnings when built.

    The directions on the Microsoft documentation site say to:

    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.

    However, there is no Compile tab (I just assumed it's the "Build" tab), and there is no Disable all warnings check box.

    Any ideas?
    Thank you.

     

    Tuesday, December 7, 2010 10:37 PM

Answers

  • Hi  tarahemphill,

     

    Welcome to MSDN Forum!

     

    C# Compiler Options Listed by Category

     

    I can get the expected result when I set "Warning Level" to "0" with no warning message displayed.

     

    The following warnings cannot be suppressed by the /nowarn option:

    Compiler Warning (level 1)

     

    So  can you provide one copy of the warning message?

    Or can you let us repro this issue in our side, so that we can try to find the root cause you're facing?

     

    Please show us a response to let us know if your problem had been solved or if the information provided is helpful on this question.

     

     

    Have a nice weekend!


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, December 12, 2010 12:35 PM
    Moderator

All replies

  • For C# the option is under the project's properties \Build -> Warning level combo.  Note however that this option does not necessarily disable all warnings.  It just disables compiler-related warnings.  Even then there might be some that the compiler always generates.  To completely suppress a warning you should use the option just below the Warning level to disable the option.

    Honestly though this is a really, really bad idea.  Unless you're compiling a PIA or some temporary code then this is almost never a good idea.  The best approach is to fix the warnings.  The next best approach is to use a #pragma warning to disable the warning around only a certain block of code.  This makes it blatantly obvious that there is something wrong with the code but you are not ready to deal with it yet.  Warnings, in most cases, identify problems with the code and should be treated like errors (at least initially).  Many companies have checkin policies that prevent code that compiles with warnings or errors from even being checked in. 

    Michael Taylor - 12/8/2010
    http://msmvps.com/blogs/p3net

    Wednesday, December 8, 2010 2:36 PM
    Moderator
  • Yes, it is temporary code (it is a project out of use, in the process of getting rid of).  I am in the process of eliminating warnings throughout the entire application, and this one project is throwing around 400.  I just wanted to disable them so I did not have to sift through them while other team members are working on safely removing it from the application.

    Like I said before, I did do that 'properties->Build->warning levl combo', but it did not seem to disable any of the 400+ warnings it's giving when I build the project.  #pragmas won't work because I need all disabled from the whole project.

     

    Thanks though

    Wednesday, December 8, 2010 5:50 PM
  • Disabling warnings are per-configuration.  Are you building the project (not solution) configuration that matches the one you changed?  Can you give an example of a warning that is not being disabled?  Note that you can suppress specific warnings for the entire project in the same dialog.  Have you tried that?

    Michael Taylor - 12/8/2010
    http://msmvps.com/blogs/p3net

    Wednesday, December 8, 2010 5:54 PM
    Moderator
  • Hi  tarahemphill,

     

    Welcome to MSDN Forum!

     

    C# Compiler Options Listed by Category

     

    I can get the expected result when I set "Warning Level" to "0" with no warning message displayed.

     

    The following warnings cannot be suppressed by the /nowarn option:

    Compiler Warning (level 1)

     

    So  can you provide one copy of the warning message?

    Or can you let us repro this issue in our side, so that we can try to find the root cause you're facing?

     

    Please show us a response to let us know if your problem had been solved or if the information provided is helpful on this question.

     

     

    Have a nice weekend!


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Sunday, December 12, 2010 12:35 PM
    Moderator