Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!samsung!viewlog.viewlogic.com!greg From: greg@suntan.viewlogic.com (Gregory Larkin) Newsgroups: comp.lang.c Subject: Question about assertion macro Message-ID: <1991May29.152228.27611@viewlogic.com> Date: 29 May 91 15:22:28 GMT Sender: news@viewlogic.com Organization: Viewlogic Systems, Inc., Marlboro, MA Lines: 30 Originator: greg@mobius Nntp-Posting-Host: mobius Hi there, I would like to construct an assertion macro so that I can print the exact condition that failed as a string. Here is the way I call the macro: ASSERT(foo != NULL, "Unexpected NULL pointer"); And here is how it is currently defined: #define ASSERT(relation, msg) { if(!(relation)) { \ printf("ASSERTION FAILED: File %s Line %d %s\n",\ __FILE__, __LINE__, msg); \ exit(FatalError); } } I would like to expand the macro so that I can print the message as: ASSERTION FAILED: foo != NULL, File xxxx Line yyyy Unexpected NULL pointer How can I print the string "foo != NULL" without passing in the test as a string. Can I print the test directly as a string somehow? Thanks for any help, -- Greg Larkin (ASIC Engineer)|"This is a fragile ball we are living on; Viewlogic Systems, Inc. |it's a miracle and we are destroying it.." 293 Boston Post Road West |Peter Garrett, Midnight Oil Marlboro, MA 01752 (greg@Viewlogic.COM)