for(int i;;)
{
}
for(int i;;)
{
}
The compiler gives the following error error C2086: 'i' : redefinition.
Is ther any way to change this behaviour to the default C++ standard of the
scope of i being within the for block .
Thanks
Firoz
example:
int i = 0;
for( i;;)
{
}
for(i;;)
{
}
Regards
Vitaly
www.chat.ru/~nurkht
Firoz Nathani <fi...@nathani.com> wrote in message
news:e1NhiDK...@cppssbbsa02.microsoft.com...
There is a way to do this with compiler option, however, you'll break
lots of things (like MFC and other supporting hosts) if you do such. There
are a few suggested workarounds for this that can be found in the VC++ FAQ:
http://www.mvps.org/vcfaq/lang/1.htm
Regards,
Joe
"Firoz Nathani" <fi...@nathani.com> wrote in message
news:e1NhiDK...@cppssbbsa02.microsoft.com...
This behavior, however, had changed several years earlier in the draft
standard, and VC++ does support it (in a very limited form) with the /Za
compiler switch. However, this switch is pretty much useless since it
disables all extensions, including those needed to compile most of the
standard headers (things like #pragmas and such are also turned off, thus
the headers won't compile).
You can easily work around this in a conformant way by placing extra braces
around your for statement:
{
for(int i...){};
}
Others will suggest using a #define which redefines 'for', which I would not
suggest. This can cause subtle side effects in existing code and can lead
to messy problems.
"Firoz Nathani" <fi...@nathani.com> wrote in message
news:e1NhiDK...@cppssbbsa02.microsoft.com...
"Joe Delekto" <jdel...@netvillage.com> wrote in message
news:OmfessLHAHA.293@cppssbbsa04...