Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - scope of variable declared in for-loop
What is the current scope of the index declared in for loops in dmc? A few years ago, it appeared that SC, as Visual C, did not obey the new scoping rules specified in the standard. Specifically, what is the scope of i? for(int i=0;i<n;i++){ .... } Ed Sowell Feb 13 2002
"Edward F. Sowell" wrote:What is the current scope of the index declared in for loops in dmc? A few years ago, it appeared that SC, as Visual C, did not obey the new scoping rules specified in the standard. Specifically, what is the scope of i? for(int i=0;i<n;i++){ .... } Feb 13 2002
Hi Jan, According to one of the most widely used C++ texts (Deitel& Deitel), it is the standard. Nonetheless, MSVC 6.0 does not follow it. Borland and DJGPP does. When I tested SC in about 98, it did not, probably following Microsoft's instincts. I am not a standards guru, so can't say for sure... Ed Sowell Jan Knepper wrote:"Edward F. Sowell" wrote:What is the current scope of the index declared in for loops in dmc? A few years ago, it appeared that SC, as Visual C, did not obey the new scoping rules specified in the standard. Specifically, what is the scope of i? for(int i=0;i<n;i++){ .... } Feb 13 2002
Jan Knepper schrieb..."Edward F. Sowell" wrote:What is the current scope of the index declared in for loops in dmc? A few years ago, it appeared that SC, as Visual C, did not obey the new scoping rules specified in the standard. Specifically, what is the scope of i? for(int i=0;i<n;i++){ .... } Feb 14 2002
No, the standard requires 'i' to be in local scope. Existing code could easyly be adapted to this new rule. BTW, I would like to have this in DMC too, could be enabled/disabled by a compiler switch. Feb 14 2002
|