🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2592

Re: New treatment of 'for (int i ...'

#2592
From: Zefram
Date: Thu, 16 Nov 1995 03:24
28 lines
1549 bytes
Fergus Henderson <fjh@munta.cs.mu.OZ.AU> wrote:
>mikes@forte.com (Mike Schilling) writes:
>>Fergus Henderson (fjh@munta.cs.mu.OZ.AU) wrote:
>>: There is a neat hack which gives you the new behaviour with old compilers:
>>:
>>:   #ifdef USE_HACK_FOR_NEW_FOR_SCOPE
>>:   #define for(x) if (0) ; else for(x)
>>:   #endif
>>Try this with:
>>
>>    for (i = 0, p = string; *p; i++, p++)
>
>Yes, that macro hack does have its disadvantages.
[convoluted "extra parentheses" solution elided]

The obvious improvement to the kludge is:

#ifdef USE_HACK_FOR_NEW_FOR_SCOPE
#define for if (0) ; else for
#endif

which solves the comma problem completely.

-zefram
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <1995Nov16.024400.790@dcs.warwick.ac.uk>
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <9531318.2076@mulga.cs.mu.OZ.AU> <9511102010.AA05887@omega.forte.com> <9531518.11584@mulga.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
Approved: fjh@cs.mu.oz.au
Date: 16 Nov 95 03:24:22 GMT
From: A.Main@dcs.warwick.ac.uk (Zefram)
Message-ID: <1995Nov16.024400.790@dcs.warwick.ac.uk>
Newsgroups: comp.std.c++
Organization: Department of Computer Science, Warwick University, England
Path: arc1-ca.pugleaf.net!in1.uu.net!bounce-back
References: <9531318.2076@mulga.cs.mu.OZ.AU> <9511102010.AA05887@omega.forte.com> <9531518.11584@mulga.cs.mu.OZ.AU>
Subject: Re: New treatment of 'for (int i ...'
X-Original-Date: Thu, 16 Nov 1995 02:44:00 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMKqvM+EDnX0m9pzZAQGYzwF9FT2iyuyTfrkqw5BJY7iruXY2JOkusoNt
 FTRBRuF9TOk1DKqdnhgAADV5aW5Bf/YP
 =2V06