Thread: RE: [GD-General] Variables scope
Brought to you by:
vexxed72
From: CAVEY G. <GER...@sg...> - 2004-02-04 14:09:07
|
>Kristoffer Gr=F6nlund wrote: > >>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 >> >Hmm... sounds like an ugly solution for something that is more simply=20 >solved by just >declaring the loop counter outside the for. 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 ... I didn t update VC 6.0 yet but maybe that the latest service pack=20 can avoid the workaround. Anyway I d better wait to get VS.NET Thanks for your help Regards GC ************************************************************************= * Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite.=20 Tout message electronique est susceptible d'alteration.=20 SG Asset Management et ses filiales declinent toute responsabilite au = titre de ce message s'il a ete altere, deforme ou falsifie. D=E9couvrez l'offre et les services de SG Asset Management sur le site www.sgam.fr=20 ******** This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited.=20 E-mails are susceptible to alteration. =20 Neither SG Asset Management nor any of its subsidiaries or affiliates = shall be liable for the message if altered, changed or falsified.=20 ************************************************************************= * |
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 |
From: Thatcher U. <tu...@tu...> - 2004-02-04 22:13:36
|
On Wed, Feb 04, 2004 at 03:46:51PM +0100, Magnus Auvinen wrote: > I've always used this: > > #define for if(false); else for > > It will behave correctly in your case as well. Those macros scare me a little; I prefer work around it explicitly with extra braces, like this: for (int i = 0; i < 10; i++) { /* whatever */ } {for (int i = 0; i < 20; i++) { /* whatever */ }} Although some people may consider that ugly. -- Thatcher Ulrich http://tulrich.com |
From: Jorrit T. <Jor...@uz...> - 2004-02-04 14:26:11
|
CAVEY GERARD wrote: >>Kristoffer Grönlund wrote: >> >> >> >>>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. >>> >>> >>> >>> >>Hmm... sounds like an ugly solution for something that is more simply >>solved by just >>declaring the loop counter outside the for. >> >> > >Hi >As Mr Aravelo(pyrostudios) told me out of list >it can also be written >#define for if (1) for >a bit simpler ... > > 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 will be the 'else' for the 'if (1)'. With the previous version of 'for' that problem is not there because there is already an 'else' branch given in the 'for' define. Greetings, |
From: Anders N. <br...@ho...> - 2004-02-04 16:13:32
|
This is not really a bug but rather a feature so service packs are not likely to change the behaviour. You can turn on "more" compliance with the C++-standard but then you get other things you might not want (anonymous unions are forbidden etc). The behavior of a language should not change with SP's (but optional features can be added though). Just use the define-hack and include it in some file that all files includes (typedefs.h or something) and then you can include it on the platforms that has the "broken" variable scopes). Anders Nilsson On Wed, 2004-02-04 at 15:09, CAVEY GERARD wrote: > >Kristoffer Grönlund wrote: > > > >>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. > >> > >> > >Hmm... sounds like an ugly solution for something that is more simply > >solved by just > >declaring the loop counter outside the for. > > Hi > As Mr Aravelo(pyrostudios) told me out of list > it can also be written > #define for if (1) for > a bit simpler ... > I didn t update VC 6.0 yet but maybe that the latest service pack > can avoid the workaround. > Anyway I d better wait to get VS.NET > Thanks for your help > > Regards > GC |
From: <ke...@ac...> - 2004-02-04 17:38:59
|
In 7.0 and up you can change the behaviour of for loops without affecting the other "extensions", there is a separate setting for it. It's not anonymous unions that are disabled with language extensions off though, but anonymous structs. Anonymous unions is valid ANSI C, I'm pret= ty sure. // Kristoffer ----- Original Message -----=20 From: "Anders Nilsson" <br...@ho...> To: <gam...@li...> Sent: Wednesday, February 04, 2004 5:15 PM Subject: RE: [GD-General] Variables scope > This is not really a bug but rather a feature so service packs are not > likely to change the behaviour. You can turn on "more" compliance with > the C++-standard but then you get other things you might not want > (anonymous unions are forbidden etc). The behavior of a language should > not change with SP's (but optional features can be added though). > > Just use the define-hack and include it in some file that all files > includes (typedefs.h or something) and then you can include it on the > platforms that has the "broken" variable scopes). > > Anders Nilsson > > On Wed, 2004-02-04 at 15:09, CAVEY GERARD wrote: > > >Kristoffer Gr=C3=B6nlund wrote: > > > > > >>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. > > >> > > >> > > >Hmm... sounds like an ugly solution for something that is more simpl= y > > >solved by just > > >declaring the loop counter outside the for. > > > > Hi > > As Mr Aravelo(pyrostudios) told me out of list > > it can also be written > > #define for if (1) for > > a bit simpler ... > > I didn t update VC 6.0 yet but maybe that the latest service pack > > can avoid the workaround. > > Anyway I d better wait to get VS.NET > > Thanks for your help > > > > Regards > > GC > > > > ------------------------------------------------------- > 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 |