Difference between DEBUG and NDEBUG?

Discussion in 'C++' started by Alexander Malkis, Apr 1, 2004.

  1. Why do programmers like to use NDEBUG instead of DEBUG?

    --
    Best regards,
    Alex.

    PS. To email me, remove "loeschedies" from the email address given.
    Alexander Malkis, Apr 1, 2004
    #1
    1. Advertising

  2. "Alexander Malkis" <-sb.de> wrote...
    > Why do programmers like to use NDEBUG instead of DEBUG?


    That's a strange question. 'DEBUG' is usually for debugging. 'NDEBUG'
    is defined when the debugging is done with. It means "NO DEBUG".

    V
    Victor Bazarov, Apr 1, 2004
    #2
    1. Advertising

  3. Alexander Malkis

    Leor Zolman Guest

    On Thu, 01 Apr 2004 04:08:27 +0200, Alexander Malkis
    <-sb.de> wrote:

    >Why do programmers like to use NDEBUG instead of DEBUG?


    It isn't that we /like/ to, it's because that's the symbol that the
    preprocessor code in <assert.h> / <cassert> specifically looks for to
    disable assertions.

    Remember, don't shoot the messenger ;-)
    -leor


    --
    Leor Zolman --- BD Software --- www.bdsoft.com
    On-Site Training in C/C++, Java, Perl and Unix
    C++ users: Download BD Software's free STL Error Message Decryptor at:
    www.bdsoft.com/tools/stlfilt.html
    Leor Zolman, Apr 1, 2004
    #3
  4. * "Victor Bazarov" <> schriebt:
    > "Alexander Malkis" <-sb.de> wrote...
    > > Why do programmers like to use NDEBUG instead of DEBUG?

    >
    > That's a strange question. 'DEBUG' is usually for debugging. 'NDEBUG'
    > is defined when the debugging is done with. It means "NO DEBUG".


    The standard assert macro is required to use NDEBUG. I don't think DEBUG
    is mentioned anywhere in the standard. Too lazy to check, though... ;-)

    --
    A: Because it messes up the order in which people normally read text.
    Q: Why is top-posting such a bad thing?
    A: Top-posting.
    Q: What is the most annoying thing on usenet and in e-mail?
    Alf P. Steinbach, Apr 1, 2004
    #4
  5. "Alf P. Steinbach" <> wrote...
    > * "Victor Bazarov" <> schriebt:
    > > "Alexander Malkis" <-sb.de> wrote...
    > > > Why do programmers like to use NDEBUG instead of DEBUG?

    > >
    > > That's a strange question. 'DEBUG' is usually for debugging. 'NDEBUG'
    > > is defined when the debugging is done with. It means "NO DEBUG".

    >
    > The standard assert macro is required to use NDEBUG. I don't think DEBUG
    > is mentioned anywhere in the standard. Too lazy to check, though... ;-)


    No, it's not defined anywhere. Many do still use it (or some variations
    of it), I believe. "Everything is allowed if not expressly prohibited".
    Victor Bazarov, Apr 1, 2004
    #5
  6. Alexander Malkis

    Mike Wahler Guest

    "Alexander Malkis" <-sb.de> wrote in message
    news:c4ftir$1ajvs$-saarland.de...
    > Why do programmers like to use NDEBUG instead of DEBUG?


    NDEBUG is a macro defined by the standard, DEBUG is not.

    -Mike
    Mike Wahler, Apr 1, 2004
    #6
  7. Alexander Malkis wrote:

    > Why do programmers like to use NDEBUG instead of DEBUG?


    ASSERT(3) Linux Programmer’s Manual ASSERT(3)

    NAME
    assert - abort the program if assertion is false

    SYNOPSIS
    #include <assert.h>

    void assert(scalar expression);

    DESCRIPTION
    If the macro NDEBUG was defined at the moment <assert.h> was last
    included, the macro assert() generates no code, and hence does
    nothing at all. Otherwise, the macro assert() prints an error
    message to standard output and terminates the program by calling
    abort() if expression is false (i.e., compares equal to zero).

    The purpose of this macro is to help the programmer find bugs in
    his program. The message "assertion failed in file foo.c,
    function do_bar(), line 1287" is of no help at all to a user.


    The assert debugging mechanism was designed to be *on* by default.
    You must define NDEBUG to turn it off.
    E. Robert Tisdale, Apr 1, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. jakk
    Replies:
    4
    Views:
    11,984
  2. A. Farber
    Replies:
    24
    Views:
    1,010
    Chris Smith
    Mar 28, 2006
  3. Alexander Malkis

    Difference between DEBUG and NDEBUG?

    Alexander Malkis, Apr 1, 2004, in forum: C Programming
    Replies:
    3
    Views:
    433
    E. Robert Tisdale
    Apr 1, 2004
  4. pereges

    NDEBUG and assert macros.

    pereges, Aug 1, 2008, in forum: C Programming
    Replies:
    5
    Views:
    5,415
    santosh
    Aug 2, 2008
  5. Alex Vinokur
    Replies:
    2
    Views:
    533
    Eric Sosman
    Jan 7, 2009
Loading...

Share This Page