Article View: comp.std.c
Article #1710Re: ANSI assert
From: Jim Patterson
Date: Thu, 13 Sep 1990 18:58
Date: Thu, 13 Sep 1990 18:58
23 lines
1378 bytes
1378 bytes
In article <1990Sep8.164857.2930@jarvis.csri.toronto.edu> norvell@csri.toronto.edu (Theo Norvell) writes:
>As has been pointed out, you may write your own assert macro. May I
>suggest
>
>#define assert_and_do(x) ((x) || assert(0))
There's a slight problem with this. While it will work, it will print
a rather misleading message with many ANSI implementations of assert (which
print out the failing condition). For example, you might see:
Failed assertion (0) at line 117 of myfile.c
when what you want to see is:
Failed assertion (x_init - x*x < EPS) at line 117 of myfile.c
It would be better, though more work and potentially less portable, to copy
and modify the definition of assert().
--
Jim Patterson Cognos Incorporated
UUCP:uunet!mitel!sce!cognos!jimp P.O. BOX 9707
PHONE:(613)738-1440 3755 Riverside Drive
Ottawa, Ont K1G 3Z4
Technical Details
Message-ID:
<8795@cognos.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!dciem!nrcaer!sce!cognos!jimpReferences:
<1428@proto.COM> <1990Sep8.164857.2930@jarvis.csri.toronto.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!dciem!nrcaer!sce!cognos!jimp From: jimp@cognos.UUCP (Jim Patterson) Newsgroups: comp.std.c Subject: Re: ANSI assert Keywords: assert, NDEBUG Message-ID: <8795@cognos.UUCP> Date: 13 Sep 90 18:58:19 GMT References: <1428@proto.COM> <1990Sep8.164857.2930@jarvis.csri.toronto.edu> Reply-To: jimp@cognos.UUCP (Jim Patterson) Organization: Cognos Inc., Ottawa, Canada Lines: 23