How to disable ASSERT (x) in C ++?

I suspect some ASSERTION code has side effects. I would like to disable ASSERT without making any changes to the way my code compiles. I am using MSVS2008. The transition from debugging to release will not be performed, as this will change the way memory is initialized.

+5
source share
2 answers

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

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

Which redefines the statement of marco so that it does not expand anything.

+6
source

If you mean assertthis should be controlled by the NDEBUG macro.

+6

All Articles