Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I exclude some specific warnings from "treat warnings as errors" without disabling them?

In my Visual C++ code I want to have /WX - "treat warnings as errors". This makes me deal with each warning, including C4996 - "X was declared deprecated" which I don't want to address - I don't want to change code at the moment and I don't want to disable C4996 so that it remains in the output. So ideally I'd like to have something like:

#pragma warning( ExcludeFromWX:4996)

so that all warnings except this one are treated as errors when /WX is used and this warning is just displayed and compilation continues.

Is it possible to get such behavior?

like image 789
sharptooth Avatar asked Mar 05 '12 12:03

sharptooth


1 Answers

You might be able to reset the specified warning by using following pragma. I did not test it though and you did not mention trying this:

UPDATE Changing the warning level should succeed

#pragma warning( 4 : 4996 )

This does not work:

#pragma warning( default : 4996 )
like image 102
Alex Avatar answered Oct 12 '22 22:10

Alex