Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!brl-adm!adm!Dizio@udel.edu From: Dizio@udel.edu Newsgroups: comp.lang.c Subject: assert Message-ID: <4907@brl-adm.ARPA> Date: Wed, 11-Mar-87 17:55:42 EST Article-I.D.: brl-adm.4907 Posted: Wed Mar 11 17:55:42 1987 Date-Received: Fri, 13-Mar-87 01:06:37 EST Sender: news@brl-adm.ARPA Lines: 38 I found this macro for assert in under ULTRIX 1.2 under the SYSTEM_FIVE #ifdef #define assert(EX) if (EX) ; else _assert("EX", __FILE__, __LINE__) ^culprit It fails when given given an expression containing '"'. eg. assert ((fp = fopen("filename","r")) != NULL) My question is this. Is this a proper implementation of this functionality. I'm not sure why it wants to pass the EX to _assert except perhaps to print the expression out, but in reality the line number and file name is all I ever need to know. This is especially true since assert is mainly a debugging tool and not anything I would put into release software. Mainly because one generally would want more control over the action to take, and the message printed to the user. The non-system define is #define _assert(ex) \ {if (!(ex)) {\ fprintf(stderr,"Assertion failed: file %s, line %d\n",\ __FILE__, __LINE__);\ exit(1);\ }} and of coarse if has no problem with any valid expression. I realize this is a minor point as I could simply write my own macro, but I just wondered if the proposed standard has specified whether any valid expression should be able to be used inside the assert, Or only expressions which don't contain '"'. Dave