Re: Keeping assert's active when not in debug mode?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 11, 2008 at 22:14, Christian Convey
<christian.convey@xxxxxxxxx> wrote:
> Is there any way I can make assert(...) macro invocations still do
> their magic, even when I build my software for release (e.g., not with
> the "-g" option)?
>

Using a custom assert macro is the most obvious way, probably, but you
could also use a custom myassert.h header that contains something like
this:

#ifdef NDEBUG
#    define ACTUALLY_IN_NDEBUG_MODE
#    undef NDEBUG
#end
#include <assert.h>
#ifdef ACTUALLY_IN_NDEBUG_MODE
#    define NDEBUG
#    undef ACTUALLY_IN_NDEBUG_MODE
#endif

But note that -g doesn't actually turn off asserts, so unless you're
using NDEBUG explicitly, you don't need to do anything.

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux