How can I turn off ASSERT( x ) in C++?

℡╲_俬逩灬. 提交于 2019-12-10 13:39:11

问题


I suspect some ASSERTION code is having side effects. I'd like to switch off ASSERT without making any other changes to how my code is compiled. I'm using MSVS2008. Switching from debug to release won't do as that will alter how memory is initialised.


回答1:


Put this at the top of your header files after the inclusions of cassert (or a include that includes cassert)

#undef assert
#define assert(x) ((void)0)

Which redefines the assert marco so that it expands to nothing.




回答2:


If you mean assert, then that should be controlled with the NDEBUG macro.



来源:https://stackoverflow.com/questions/2246096/how-can-i-turn-off-assert-x-in-c

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