RE: [GD-General] Variables scope
Brought to you by:
vexxed72
|
From: Magnus A. <mag...@st...> - 2004-02-04 14:47:02
|
I've always used this:
#define for if(false); else for
It will behave correctly in your case as well.
-----Original Message-----
From: Jorrit Tyberghein [mailto:Jor...@uz...]=20
Sent: den 4 februari 2004 15:25
To: gam...@li...
Subject: Re: [GD-General] Variables scope
CAVEY GERARD wrote:
>>Kristoffer Gr=F6nlund wrote:
>>
>> =20
>>
>>>The way I've worked around this in the past has been by redefining =
for as
>>>follows:
>>>#define for if (false) {} else for
>>>
>>>Yes, it's a hideously ugly hack, but so is the problem in the first
place.
>>>I've never had any problems because of it.
>>>=20
>>>
>>> =20
>>>
>>Hmm... sounds like an ugly solution for something that is more simply =
>>solved by just
>>declaring the loop counter outside the for.
>> =20
>>
>
>Hi=20
>As Mr Aravelo(pyrostudios) told me out of list
>it can also be written=20
>#define for if (1) for
>a bit simpler ...
> =20
>
Yes but that can give bad results. For example:
if (a > b)
for (...)
else
...
With your version of 'for' the 'else' branch will never execute since =
it=20
will be
the 'else' for the 'if (1)'. With the previous version of 'for' that=20
problem is not there
because there is already an 'else' branch given in the 'for' define.
Greetings,
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Gamedevlists-general mailing list
Gam...@li...
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=3D557
|