"Christophe Grimault" wrote on 14 Oct 03:
Hi all,
look at the following code:
//////////////////////////
for(int i = 0; i<10; i++)
cout << i;
for(int i = 0; i<20; i++)
cout << i;
//////////////////////////
It compiles and runs under gcc. However, when I give code like this
to somebody who tries to run it under MSVC++6, it seems complains about
redefinition of i, in the second loop...
Is there a compiler option to set for MSVC++6 to accept this ?
That behaviour is a Microsoft Extension to the C++ Standard. The only
way to allow what you've prevented is to disable (*ALL*) the language
extensions. This can be done in the project settings through either
the check-box, or by adding /Za anywhere to the switches list at the
bottom of most option pages. Be warned though: this could cause a lot
of problems if you do rely on some of the extensions, so it might be
easier to do a single declaration:
Read "Disable Language Extensions" for some more information.
Mike
P.S. This derives from KB article Q167748 which refers to VC++ 5.0. I
think it will apply, but if not, assume that there is no solutions
other than a single declaration.
--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)