[Top][All Lists]

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

Re: How to enable/disable my debug code?

From: Gary V. Vaughan
Subject: Re: How to enable/disable my debug code?
Date: Wed, 27 Jul 2011 13:36:49 +0700

On 27 Jul 2011, at 12:56, narke wrote:
> With a same set of autoconf/automake files, how to I distribute my
> program that allows user to build it with or without debug code
> enabled?  In my code, there are something like below:
> #if (__MY_DEBUG__)
> ...
> #endif
> Thanks in advance.

For debug builds:

  ./configure CFLAGS='-g' CPPFLAGS=-D__MY_DEBUG__

For regular builds:


If you use assert.h, you can also speed things up a bit more by turning
off the assertions with:

  ./configure CPPFLAGS=-DNDEBUG

Of course you can write (or find and copy) some Autoconf M4 code to
do some or all of the above automatically depending on the presence
of configure options like:

  ./configure --enable-debug

Googling for 'AC_ARG_ENABLE debug' turns up many examples such as:

    [  --enable-debug           build with additional debugging code],

Gary V. Vaughan (gary AT gnu DOT org)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]