Difference between DEBUG and NDEBUG?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Alexander Malkis

    Difference between DEBUG and NDEBUG?

    Why do programmers like to use NDEBUG instead of DEBUG?

    --
    Best regards,
    Alex.

    PS. To email me, remove "loeschedie s" from the email address given.
  • Victor Bazarov

    #2
    Re: Difference between DEBUG and NDEBUG?

    "Alexander Malkis" <alexloeschedie smalk@stone.cs. uni-sb.de> wrote...[color=blue]
    > Why do programmers like to use NDEBUG instead of DEBUG?[/color]

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

    V


    Comment

    • Leor Zolman

      #3
      Re: Difference between DEBUG and NDEBUG?

      On Thu, 01 Apr 2004 04:08:27 +0200, Alexander Malkis
      <alexloeschedie smalk@stone.cs. uni-sb.de> wrote:
      [color=blue]
      >Why do programmers like to use NDEBUG instead of DEBUG?[/color]

      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:
      An STL Error Decryptor for C++ by Leor Zolman of BD Software - available to download here

      Comment

      • Alf P. Steinbach

        #4
        Re: Difference between DEBUG and NDEBUG?

        * "Victor Bazarov" <v.Abazarov@com Acast.net> schriebt:[color=blue]
        > "Alexander Malkis" <alexloeschedie smalk@stone.cs. uni-sb.de> wrote...[color=green]
        > > Why do programmers like to use NDEBUG instead of DEBUG?[/color]
        >
        > That's a strange question. 'DEBUG' is usually for debugging. 'NDEBUG'
        > is defined when the debugging is done with. It means "NO DEBUG".[/color]

        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?

        Comment

        • Victor Bazarov

          #5
          Re: Difference between DEBUG and NDEBUG?

          "Alf P. Steinbach" <alfps@start.no > wrote...[color=blue]
          > * "Victor Bazarov" <v.Abazarov@com Acast.net> schriebt:[color=green]
          > > "Alexander Malkis" <alexloeschedie smalk@stone.cs. uni-sb.de> wrote...[color=darkred]
          > > > Why do programmers like to use NDEBUG instead of DEBUG?[/color]
          > >
          > > That's a strange question. 'DEBUG' is usually for debugging. 'NDEBUG'
          > > is defined when the debugging is done with. It means "NO DEBUG".[/color]
          >
          > 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... ;-)[/color]

          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".


          Comment

          • Mike Wahler

            #6
            Re: Difference between DEBUG and NDEBUG?


            "Alexander Malkis" <alexloeschedie smalk@stone.cs. uni-sb.de> wrote in message
            news:c4ftir$1aj vs$1@hades.rz.u ni-saarland.de...[color=blue]
            > Why do programmers like to use NDEBUG instead of DEBUG?[/color]

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

            -Mike


            Comment

            • E. Robert Tisdale

              #7
              Re: Difference between DEBUG and NDEBUG?

              Alexander Malkis wrote:
              [color=blue]
              > Why do programmers like to use NDEBUG instead of DEBUG?[/color]

              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.

              Comment

              Working...