Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84 chuqui version 1.7 9/23/84; site daisy.UUCP Path: utzoo!dciem!nrcaero!pesnta!hplabs!nsc!daisy!pkl From: pkl@daisy.UUCP (Peter K. Lee) Newsgroups: net.lang.c Subject: Re: C-Debug package ... (a la "context-independent macros") Message-ID: <33@daisy.UUCP> Date: Sat, 26-Jan-85 02:49:30 EST Article-I.D.: daisy.33 Posted: Sat Jan 26 02:49:30 1985 Date-Received: Mon, 28-Jan-85 02:13:48 EST References: <1885@wateng.UUCP> <1089@hcrvx1.UUCP> Organization: Daisy Systems Corp., Mountain View, Ca Lines: 30 > Whenever I define a macro to be an expression, I put parens around it > to avoid surprises. Similarly, whenever I define a macro to be a > (compound) statement, I put braces around it. There are two places > where braces cause problems: IF statements with ELSE clauses and > DO statements: > hugh@hcrvx1 I learned this from Dave Ungar while working on the Berkeley Smalltalk project. # define macro(args)\ if (1) {\ /* macro body */\ /* goes here */;\ }\ else Notice that the trailing "else" will take care of the ";". A macro defined this way can go wherever a legal C statement can go because this IS a legal C statement (when you call it as macro(args);). If you think that "if (1)" is silly and may generate inefficient code, you better go find a better compiler. -- -- Peter Lee ...{ucbvax!amd,decwrl,ihnp4}!nsc!daisy!pkl [No news is good news]