Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Difference between DEBUG and NDEBUG?

Reply
Thread Tools

Difference between DEBUG and NDEBUG?

 
 
Alexander Malkis
Guest
Posts: n/a
 
      04-01-2004
Why do programmers like to use NDEBUG instead of DEBUG?

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      04-01-2004
"Alexander Malkis" <> 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


 
Reply With Quote
 
 
 
 
Leor Zolman
Guest
Posts: n/a
 
      04-01-2004
On Thu, 01 Apr 2004 04:08:27 +0200, Alexander Malkis
<> 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
 
Reply With Quote
 
Alf P. Steinbach
Guest
Posts: n/a
 
      04-01-2004
* "Victor Bazarov" <> schriebt:
> "Alexander Malkis" <> 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?
 
Reply With Quote
 
Victor Bazarov
Guest
Posts: n/a
 
      04-01-2004
"Alf P. Steinbach" <> wrote...
> * "Victor Bazarov" <> schriebt:
> > "Alexander Malkis" <> 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".


 
Reply With Quote
 
Mike Wahler
Guest
Posts: n/a
 
      04-01-2004

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


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

-Mike


 
Reply With Quote
 
E. Robert Tisdale
Guest
Posts: n/a
 
      04-01-2004
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 04-15-2011 04:00 AM
FAQ 7.17 What's the difference between dynamic and lexical (static) scoping? Between local() and my()? PerlFAQ Server Perl Misc 0 01-06-2011 05:00 PM
Difference between bin and obj directories and difference between project references and dll references jakk ASP .Net 4 03-22-2005 09:23 PM
Difference between DEBUG and NDEBUG? Alexander Malkis C Programming 3 04-01-2004 03:37 AM
Exact difference between 'const char *' and 'char *', also diff between 'const' and 'static' Santa C Programming 1 07-17-2003 02:10 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57