disable warning c4702 seems not work for VS 2012

若如初见. 提交于 2019-11-29 09:28:10

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
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!