[OT] Re: assert{ 2.0 } - a new kind of assertion



On 29.01.2008 19:02, Paul E. Black wrote:
Very nice! I've used C's macro pre-processor to do something like
that for some 20 years.

#ifdef RIGOROUS
#define ASSERT(ex) {if(!(ex))fprintf(stderr,"ex false in %s, line %d\n",__FILE__,__LINE__);}
#else
#define ASSERT(ex)
#endif

My C is a bit rusty these days but isn't it safer to define the non assertion case as

#defind ASSERT(ex) /* ex */

i.e. at least generate an empty comment? Otherwise you get only whitespace and parsing of the source my change.

Kind regards

robert
.



Relevant Pages