Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 995
jbcoe Avatar asked Feb 11 '10 16:02

jbcoe


1 Answers

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.

like image 172
Yacoby Avatar answered Sep 28 '22 07:09

Yacoby