Subject:
|
Re: Design by Contract (long post)
|
Newsgroups:
|
lugnet.robotics.rcx
|
Date:
|
Thu, 8 Jan 2004 16:57:55 GMT
|
Viewed:
|
3239 times
|
| |
| |
In lugnet.robotics.rcx, Ross Crawford wrote:
|
|
#ifdef NDEBUG
#define assert(x) ((void)0)
#else
#define assert(x) if (x) {} else { assert_fail(); }
#endif
|
I have a question about this: If NDEBUG is defined, shouldnt it still
execute x? That is, shouldnt the code in assert.h (or wherever) be:
#ifdef NDEBUG
#define assert(x) (x)
#else
#define assert(x) if (x) {} else { assert_fail(); }
#endif
ROSCO
|
I agree it seems to be the wrong way round. Thats the standard implementation.
NDEBUG seems to stand for No debug. One advantage of making it negative, is
that you get the assert()s if you dont do anything (ie dont define NDEBUG).
BTW, this thread should of course have been in the BrickOS group. Noob mistake
:)
|
|
Message is in Reply To:
| | Re: Design by Contract (long post)
|
| (...) Hi Iain! (...) Cool! (...) I have a question about this: If NDEBUG is defined, shouldn't it still execute x? That is, shouldn't the code in assert.h (or wherever) be: #ifdef NDEBUG #define assert(x) (x) #else #define assert(x) if (x) else (...) (21 years ago, 8-Jan-04, to lugnet.robotics.rcx, FTX)
|
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|