Article View: comp.std.c
Article #3145Re: macors and semicolons
From: Doug Gwyn
Date: Mon, 24 Jun 1991 16:53
Date: Mon, 24 Jun 1991 16:53
9 lines
847 bytes
847 bytes
In article <1991Jun24.213932.595@otago.ac.nz> andrew@otago.ac.nz writes:
>#define SWAP(a, b) {int c; c = a; a = b; b = c}
>how do I define a swap macro that swaps two doubles, allows the ';' on the end
>of the macro call, but does not cause a systax error when used in this context?
This is not a C standards question.
One obvious general solution is:
#define MACRO(args) do { /*...*/ } while(0)
Technical Details
Message-ID:
<16519@smoke.brl.mil>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!hsdndev!cmcl2!adm!smoke!gwynReferences:
<1991Jun24.213932.595@otago.ac.nz>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!ncar!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.std.c,comp.lang.c Subject: Re: macors and semicolons Message-ID: <16519@smoke.brl.mil> Date: 24 Jun 91 16:53:47 GMT References: <1991Jun24.213932.595@otago.ac.nz> Followup-To: comp.lang.c Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 9