Re: [Plib-devel] PLIB developers needed.
Brought to you by:
sjbaker
From: Sam S. <sa...@sp...> - 2000-08-10 13:03:10
|
----- Original Message ----- From: "Gil Carter" <g.c...@ca...> To: <pli...@li...> Sent: Thursday, August 10, 2000 7:13 AM Subject: Re: [Plib-devel] PLIB developers needed. > > >Linux people: Please don't do this: > > > > for ( int i = 0 ; i < 10 ; i++ ) whatever ; > > for ( int i = 0 ; i < 20 ; i++ ) whatever ; > > > >(Although it's perfectly legal C++ - MSVC barfs on it - I forget > > about this *every* time - sorry Windoze dudes!) > > But to credit Leath Muller (I think), this will fix that problem: > > { for ( int i = 0 ; i < 10 ; i++ ) whatever ; } > { for ( int i = 0 ; i < 20 ; i++ ) whatever ; } > > But it's daggy and isn't something you'd write given a choice :-) I believe the revised ANSI C++ scoping rules now forbid declaration of variables in a for statement, completely. But this is fairly recent, so different compilers are still tolerating it in different ways. The scoping for this sort of declaration was always cloudy at best, so it's probably for the best. Bottom line - don't do it. Sam |