473,383 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Difference between DEBUG and NDEBUG?

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
6 25380
"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
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
* "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
"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

"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Alexander Malkis | last post by:
Why do programmers like to use NDEBUG instead of DEBUG? -- Best regards, Alex. PS. To email me, remove "loeschedies" from the email address given.
11
by: Markus Dehmann | last post by:
I have a static const bool debug = false; variable in my class. Debug output goes like this, trivially: if(debug) cerr << "debug message"; Is it guaranteed that this if/then clause is always...
7
by: Techno Learner | last post by:
Sorry for the lame question but, what's the difference between Debug and Release versions?
1
by: Egbert Nierop \(MVP for IIS\) | last post by:
Hi, I have had AtlTrace statements, but for file logging and debugging purposes, I wrote something similar. But when I release the code, the compiler does not 'ignore' the statements just as...
6
by: bantamweight | last post by:
Hi, I create a project with vs2005 (both c++ and c# are used, sames the problem is about c++) and it working well in Debug version but the result is wrong in Release version. I checked again and...
9
by: Bern McCarty | last post by:
I am porting stuff from MEC++ syntax to the new C++/CLI syntax. Something that we did in the old syntax that proved to be very valuable was to make sure that the finalizer would purposefully...
5
by: sujeet | last post by:
Dear friends, I'm facing a strange problem... My Application is in Debug mode, and the third party static library i'm using is in release mode. When i compile and try to link my...
7
by: Khookie | last post by:
Hi everyone The program I'm writing is getting bigger, hence not as easy to debug. So I have this on one of my core header files, which I include in just about every .c file, and I use it...
2
by: ciccio | last post by:
Hi, I would like to write debug output to my screen but I don't want to use std::cout or std::cerr but rather a thing called debug which would write to std:cerr. Also I would like to have that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.