Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site ncoast.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!cwruecmp!atvax!ncoast!bsa From: bsa@ncoast.UUCP (Brandon Allbery) Newsgroups: net.lang.c Subject: Re: C-Debug package ... (a la "context-independent macros") Message-ID: <591@ncoast.UUCP> Date: Mon, 11-Feb-85 10:46:38 EST Article-I.D.: ncoast.591 Posted: Mon Feb 11 10:46:38 1985 Date-Received: Fri, 15-Feb-85 04:38:35 EST References: <1885@wateng.UUCP> <1089@hcrvx1.UUCP> <33@daisy.UUCP> <1097@hcrvx1.UUCP> <1924@wateng.UUCP> Reply-To: bsa@ncoast.UUCP (Brandon Allbery) Organization: North Coast Programming, Cleveland Lines: 33 Summary: > Article <1924@wateng.UUCP>, from ksbszabo@wateng.UUCP (Kevin Szabo) +---------------- | In article <33@daisy.UUCP> pkl@daisy.UUCP (Peter K. Lee) writes: | > # define macro(args)\ | > if (1) {\ | > /* macro body */\ | > }\ | > else | | I am also not going to use Peter's suggestion because it too can cause | un-obvious behavior, but this time if the user makes a small syntax | error. Suppose I forget the semicolon when I call the macro? | ... | I also find the macro definition hard to read...whenever I see an | `else' I expect it to be controlling something. Very confusing. The answer was posted about 3 months ago. #define macro(args)\ do\ {\ /* macro body */\ }\ while (0) The body is executed exactly once, since the condition isn't found to b false until the end... and a missing semicolon will show up as a syntax error, which is reasonable. Brandon (bsa@ncoast.UUCP) -- Brandon Allbery, decvax!cwruecmp!ncoast!bsa, "ncoast!bsa"@case.csnet (etc.) 6504 Chestnut Road, Independence, Ohio 44131 +1 216 524 1416 (or what have you)