By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,247 Members | 1,165 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,247 IT Pros & Developers. It's quick & easy.

Difference between DEBUG and NDEBUG?

P: n/a
Why do programmers like to use NDEBUG instead of DEBUG?

--
Best regards,
Alex.

PS. To email me, remove "loeschedies" from the email address given.
Jul 22 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
"Alexander Malkis" <al*****************@stone.cs.uni-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
Jul 22 '05 #2

P: n/a
On Thu, 01 Apr 2004 04:08:27 +0200, Alexander Malkis
<al*****************@stone.cs.uni-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
Jul 22 '05 #3

P: n/a
* "Victor Bazarov" <v.********@comAcast.net> schriebt:
"Alexander Malkis" <al*****************@stone.cs.uni-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?
Jul 22 '05 #4

P: n/a
"Alf P. Steinbach" <al***@start.no> wrote...
* "Victor Bazarov" <v.********@comAcast.net> schriebt:
"Alexander Malkis" <al*****************@stone.cs.uni-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".
Jul 22 '05 #5

P: n/a

"Alexander Malkis" <al*****************@stone.cs.uni-sb.de> wrote in message
news:c4************@hades.rz.uni-saarland.de...
Why do programmers like to use NDEBUG instead of DEBUG?


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

-Mike
Jul 22 '05 #6

P: n/a
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.

Jul 22 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.