Re: c++ build question
On Nov 2, 12:04 pm, Pete Becker <p...@versatilecoding.com> wrote:
James Kanze wrote:
Note that _DEBUG is a special symbol, whose effects are
defined by the standard, and that it is not designed to be
defined in the command line or at the top of the code, but
rather somewhere within the code, before including
<assert.h> (for a second time), so that you only turn off
assertions around the critical block, and not everywhere.
Umm, that's NDEBUG. _DEBUG is often used to indicate a debug
build, but that's a convention, not a requirement.
Oops. And the _DEBUG convention is doubtlessly one from the
compiler implementer (or implementers, since it is likely used
by more than one), since the name is in the implementation's
namespace.
In practice, you do want something other than NDEBUG, since what
you want around the time critical parts is something like:
#ifdef _DEBUG
#define NDEBUG
#include <assert.h>
#endif
// Critical function...
#undef NDEBUG
#include <assert.h>
(Although in practice, I find that just having one flag for
debug, in such cases, is awkward. You often want different
levels, rather than an on/off switch, and you often want
different subsystems to use different levels.)
--
James Kanze