I have some code for testing that i added upfront the rest of the code, so the rest would never be reached in the test. Since i have warning level 4 set, this results in an c4702: unreachable-code warning
I tried disabling like this:
//do something
return 0;
/*-------------------------------------------------------------------------*/
#pragma warning(disable: 4702)
//real code
but the compiler still moans. And because i have set to treat every warning as an error, this won't compile...
I am using Visual Studio 2012 Premium...
Any help would be gladly appreciated.
You maybe just need to place the pragma before the start of the affected function rather than inside it.
From the MSDN docs:
For warning numbers in the range 4700-4999, which are the ones associated with code generation, the state of the warning in effect when the compiler encounters the open curly brace of a function will be in effect for the rest of the function. Using the warning pragma in the function to change the state of a warning that has a number larger than 4699 will only take effect after the end of the function.
So for example:
#pragma warning(push)
#pragma warning(disable: 4702)
bool Do() {
return true;
return true; // No warning generated
#pragma warning(pop)
}
bool DoDo() {
return true;
return true; // Generates C4702
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With