Hello guys could anyone explain what is the point in: #define DEBUG and #define NDEBUG?
when should we use them and how?? I'd like to see some examples
any help is highly appreciated
ProDev7
0
Newbie Poster
Recommended Answers
Jump to Postdepends on the compiler. Generally, DEBUG is defined when you want to compile the program for debugging -- the compiler adds a great deal of symbol information and data so that you can use a debugger to single-step through the program and view the value of variables at any given …
Jump to PostWhen you define DEBUG you can adjust what your code does based on this definition.
So you could do;
#define _DEBUG #include <iostream> int main(int argc, char** argv) { #ifdef _DEBUG std::cout << "DEBUG MODE ON" << std::endl; #else std::cout << "DEBUG MODE OFF" << std::endl; #endif …
All 8 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
ProDev7
0
Newbie Poster
Ketsuekiame
860
Master Poster
Featured Poster
ProDev7
0
Newbie Poster
Ketsuekiame
860
Master Poster
Featured Poster
Moschops
683
Practically a Master Poster
Featured Poster
ProDev7
0
Newbie Poster
ProDev7
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.