Question about assertion macro
Gregory Larkin
greg at suntan.viewlogic.com
Thu May 30 01:22:28 AEST 1991
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 at Viewlogic.COM)
More information about the Comp.lang.c
mailing list