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

2019-06-22 18: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.

2条回答
Anthone
2楼-- · 2019-06-22 18:27

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

查看更多
地球回转人心会变
3楼-- · 2019-06-22 18:38

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.

查看更多
登录 后发表回答