[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppNdebug
It is used commonly for removing assert statements, but also for similar debugging checks.
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppNdebug
(C/C++) NDEBUG
#define used for debugging.It is used commonly for removing assert statements, but also for similar debugging checks.
int main() { //Common assert statement assert(2==3); //Of course, this is never true //Similar debugging check std::vector<double> myVector(10);
- define NDEBUG
- include <iostream>
- include <vector>
- include <assert.h>
//The statement below is a sleeping error myVector[10]=69.69; //Performs NO range check -> unsafe, quick
- ifdef NDEBUG
myVector.at(10)=69.69; //Performs range check -> safe, slow
- else
return 0; }
- endif
Code links
Links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
