This question already has an answer here:

When we are working on a big project of C or CPP, we are getting some warning. Therefore, we try to remove that warning because when we see compiler warnings that they make us feel dirty. When we search about specific warning, We get some solution to disable specific warnings.

So, I have a question, Is it really good idea to disable warning?

marked as duplicate by Doc Brown, Bart van Ingen Schenau, gnat, Dan Pichelman, BobDalgleish Sep 12 at 13:38

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 3
    No that's not a good idea, you should fix the warnings instead. They are there for a reason. – πάντα ῥεῖ Sep 12 at 6:05
  • 1
    Short answer: no. Long answer: if the project is big and they aren't particularly serious warnings, you can disable at least on your local copy during compilation so that you don't regularly see them. I would still avoid committing changes which include disabling warnings, as it isn't a "fix" by any means. – Neil Sep 12 at 6:22
  • 1
    See also Compiler Warnings – Doc Brown Sep 12 at 6:22
  • 1
  • there are cases where some warning could be ignored, you should always assume though that a warning is justified. The reason that it's a warning and not an error is that you are able to choose to ignore/ live with it. Some warnings are just bad luck and can't be avoided specially when working with 3rd party code. In General however set the compiler to treat warnings as errors and disable them in code using a reason – PPann Sep 12 at 7:19

Errors are there to stop you doing things are not allowed like walking across Niagara Falls on foot (without any ropes or anything). It just can't be done, so the compiler say "No".

Warning are there for things that you might get away with, but you probably shouldn't try, like walking across Niagara Falls on a tightrope. Yes, some really, really skilful people can to this, but it's more likely that you're going to get wet (at best).

If anything, you should go the other way and promote Warnings into Errors and close the door on all these potential problems.

Failing that, if you really can't avoid a warning, then suppress that single instance of the warning: https://stackoverflow.com/questions/7159348/disable-single-warning-error

This is likely to work well, because it's more work for Developer(s).
They're more likely to take the "easy" option and fix the underlying problem instead of writing all those fiddly "extra" pragma statements. :-)

Don't be tempted to "forget" about warnings globally.

Not the answer you're looking for? Browse other questions tagged or ask your own question.