Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!wuarchive!mailrus!sharkey!rjf001!amara!mcdaniel From: mcdaniel@adi.com (Tim McDaniel) Newsgroups: comp.lang.c Subject: Re: Using Macros Message-ID: Date: 7 Aug 90 22:59:51 GMT References: <362.26be9dcc@astro.pc.ab.com> Sender: news@adi.COM Organization: Applied Dynamics Int'l. Lines: 17 In-reply-to: yoke@astro.pc.ab.com's message of 7 Aug 90 15:54:04 GMT yoke@astro.pc.ab.com (Michael Yoke) asks about multiple-statement macros. 1. The comma operator, which only works for expressions: #define A_MACRO (expr1, ..., exprn) 2. #define A_MACRO do { stmt1; ...; stmtn; } while (0) Any decent compiler should optimize the useless test out. Even if it doesn't, it shouldn't hurt speed much. Lint may require help to shut up about a "constant in a conditional context", or such. -- "I'm not a nerd -- I'm 'socially challenged'." Tim McDaniel Internet: mcdaniel@adi.com UUCP: {uunet,sharkey}!amara!mcdaniel