Path: utzoo!yunexus!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!usc!apple!oracle!news From: fmcwilli@oracle.oracle.com (Floyd McWilliams) Newsgroups: comp.lang.c Subject: mixstrcpy() macro (was Re: Using small memory model...) Summary: Prevent parsing problems Message-ID: <1990May29.164824.21724@oracle.com> Date: 29 May 90 16:48:24 GMT Article-I.D.: oracle.1990May29.164824.21724 References: <90052709560067@masnet.uucp> <1990May28.000424.20473@druid.uucp> <1990May28.190935.22913@druid.uucp> Reply-To: fmcwilli@oracle.com (Floyd W. McWilliams) Organization: Oracle Corporation, Belmont, CA Lines: 25 In article <1990May28.190935.22913@druid.uucp> darcy@druid.UUCP (D'Arcy J.M. Cain) writes: >#define mixstrcpy(d, s) { int k = 0; do d[k] = s[k]; while (s[k++]);} This blows up if you try if (d && s) mixstrcpy(d,s); else ... (The semicolon after the mixstrcpy() invocation becomes a null statement, and the "else" is left hanging.) Try wrapping the macro in do ... while(0), like this: #define mixstrcpy(d,s) \ do \ { int k = 0; do d[k] = s[k]; while (s[k++]); } \ while(0) Hope this helps(TM). -- Floyd McWilliams -- fmcwilli@oracle.com To be esteemed be useful.