Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!purdue!ames!oliveb!tymix!cirrusl!sun600!paul From: paul@sun600.UUCP (Paul E. Black) Newsgroups: comp.lang.c++ Subject: Re: A C++ Macro Package implementing *Assertions* (was: Re: Eiffel vs. C++) Message-ID: <764@cirrusl.UUCP> Date: 8 Jun 89 20:06:00 GMT References: <2689@ssc-vax.UUCP> <77300029@p.cs.uiuc.edu> Sender: news@cirrusl.UUCP Reply-To: paul@sun600 (Paul E. Black) Organization: CIRRUS LOGIC Inc. Lines: 33 Here's our version of an "assert" (run-time check) macro. /* *created "Wed Oct 9 13:16:25 1985" *by "Paul E. Black" */ /* *modified "Mon Oct 19 13:20:35 1987" *by "Paul E. Black" */ /*------------------------------------------------------------------------*/ /* * This file contains a macro definition for ASSERT. In your code you * can place statements like: * ASSERT(0 <= row && pNodePtr->rowSize > 3); * If your program is compiled with RIGOROUS defined, for example * cc -DRIGOROUS ..., the assertion is checked. If RIGOROUS is not * defined, the assertion creates no code. Therefore you can ASSERT * very complex or time consuming things, e.g. foo should be in a table, * which you would not want to check during normal operation. * * This ASSERT differs from the C standard "assert" in that no exit() * or abort() occurs: there is only a message to stderr. Also the * default is that ASSERT does nothing and must be turned on, whereas * "assert" is on as a default and must be turned off. */ /*------------------------------------------------------------------------*/ #ifdef RIGOROUS #define ASSERT(ex) {if (!(ex)) (void)fprintf(stderr,"ex not true in %s, line %d\n",__FILE__,__LINE__);} #else #define ASSERT(ex) #endif Paul E. Black | UUCP: ...{pyramid,amdahl,ames}!oliveb!cirrusl!paul CIRRUS LOGIC, Inc. | Internet: cirrusl!paul@olivetti.com 1463 Centre Pointe Dr. | Voice: 408-945-8305 extension 210 Milpitas, CA 95035 USA