Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!zaphod.mps.ohio-state.edu!rpi!crdgw1!underdog!volpe From: volpe@underdog.crd.ge.com (Christopher R Volpe) Newsgroups: comp.lang.c Subject: Re: Using Macros Message-ID: <10836@crdgw1.crd.ge.com> Date: 7 Aug 90 17:55:36 GMT References: <14339@shlump.nac.dec.com> Sender: news@crdgw1.crd.ge.com Reply-To: volpe@underdog.crd.ge.com (Christopher R Volpe) Lines: 30 In article <14339@shlump.nac.dec.com>, farrell@onedge.enet.dec.com (Bernard Farrell) writes: |> |>In article <362.26be9dcc@astro.pc.ab.com>, yoke@astro.pc.ab.com (Michael Yoke) writes... |>>But, if I define the macro like this |>> |>> #define A_MACRO { stmt1; stmt2; } |>> |>>then the semi-colon at the end of the macro reference screws things up. |>> |>The presence of an empty statement after |>the closing brace should not cause any problems, though I seem to recall |>certain C compilers don't like it being placed here. Can someone with a copy of the Standard tell us if a semicolon is allowed? K&R2 is vague on the issue ("there is no semicolon after the closing brace". Does this mean "no semicolon necessary" or "no semicolon allowed"?). Anyway, if the compiler is coughing on it, try the following: #define A_MACRO {stmt1;stmt2;} 0 /* yes, trailing zero */ Expanding "A_MACRO;" yields the dummy statement "0;" which is basically a value that goes unused, much like ignoring the return value of a function, except that no function gets called and no code (should) be generated. (Sun C and GNU C accept "0;" as a statement and generate no code.)