Friday, April 29, 2011

Warning as Error, but not all

I would like to enable Warning as Error on our current project/solution for obvious reasons.

There are several warnings that should NOT be handled as an error, eg Obsolete, and using #warning directives.

Is this possible?

I see that I can make specific warnings behave as errors, but I would really like the 'invert' of that.

The closest I can get is disabling the 2 above mentioned warnings, but then there will be no 'warning' for them either.

Any suggestions?

To clarify:

I want the warnings, just not as an error. So all warning except for the above mentioned exceptions will behave as an error, and the above mentioned will be warnings (ones I can see in the compiler results).

From stackoverflow
  • The warnaserror compiler option supports erroring only on specific warnings. You can thus specify all warnings to be shown as an error, then disable the errors for certain warnings. Using the page's example as a guide:

    leppie : Yes, that is what I want, not sure if that works, but will try :) Thanks!
  • It is possible in VS2005 assuming you are using C#.


    In Visual Studio 2005, you have a couple more options to control this. Now, you have 3 options for treating warnings as errors: All, None, or Specific Warnings, where you can provide a semi-colon separated list of error numbers.

    It is also possible to do it with GCC with the option -Werror=

    leppie : I want to opposite, see stragers answer, he seems to understand the issue :)


Post a Comment