Are asserts disabled in 'release' build?
How optional flags like -O0
,-O3
,-g
of g++
affects it's behaviour?
Are asserts disabled in 'release' build?
How optional flags like -O0
,-O3
,-g
of g++
affects it's behaviour?
assert()
in the <cassert>
header is only disabled if you define the macro NDEBUG
prior to including the <cassert>
header file. See also these docs
With gcc/g++, the easiest way to do so is to define the NDEBUG
macro on the command line when invoking the compiler like so:
g++ -DNDEBUG ... other args...
Arguments such as optimization flags and similar flags does not disable the assert.
From the man page:
If the macro NDEBUG was defined at the moment
assert.h
was last included, the macro assert() generates no code