[Python-Dev] Visibility scope for "for/while/if" statements
Josiah Carlson
jcarlson at uci.edu
Thu Sep 22 22:58:08 CEST 2005
More information about the Python-Dev mailing list
Thu Sep 22 22:58:08 CEST 2005
- Previous message: [Python-Dev] Visibility scope for "for/while/if" statements
- Next message: [Python-Dev] Visibility scope for "for/while/if" statements
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alexander Myodov <maa_public at sinn.ru> wrote: > >> "for (int i = 0; i < 10; i++)" works fine nowadays. > JC> I'm sorry, but you are wrong. The C99 spec states that you must define > JC> the type of i before using it in the loop. Maybe you are thinking of > JC> C++, which allows such things. > "gcc -std=c99" compiles the line "for (int i = 0; i <= 5; i++);" > perfectly. Along with another sample mentioned above . > To this day, I relied upon gcc in terms of standards compatibility... I misread the error message from my compiler. It /only/ works in C99 mode. Previous C standards (which CPython itself conforms to) did not allow such things. Interestingly enough, not all C++ compilers (Microsoft) hid variables created in for loops (http://www.devx.com/cplus/10MinuteSolution/28908/0/page/2). - Josiah
- Previous message: [Python-Dev] Visibility scope for "for/while/if" statements
- Next message: [Python-Dev] Visibility scope for "for/while/if" statements
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list