Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!brutus.cs.uiuc.edu!jarthur!aqdata!sullivan From: sullivan@aqdata.uucp (Michael T. Sullivan) Newsgroups: comp.lang.c Subject: Re: Is this swap() macro correct? Message-ID: <1990Jan18.002842.441@aqdata.uucp> Date: 18 Jan 90 00:28:42 GMT References: <21068@stealth.acf.nyu.edu> Distribution: usa Organization: aQdata, Inc. Western Region -- San Dimas, CA Lines: 15 From article <21068@stealth.acf.nyu.edu>, by brnstnd@stealth.acf.nyu.edu: > Say swap() is defined as > > #define block do { > #define endblock } while(0) > #define swap(x,y,typ) block typ *_MV_x = x; typ *_MV_y = y; typ tmp;\ > tmp = *_MV_x; *_MV_x = *_MV_y; *_MV_y = tmp; endblock Why are "block" and "endblock" even bothered with here. Why not just put the "do {" and "} while (0)" in the definition of swap? Could somebody please enlighten me. -- Michael Sullivan uunet!jarthur!aqdata!sullivan aQdata, Inc. sullivan@aqdata.uucp San Dimas, CA