469,592 Members | 1,757 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

a real strange C4288

I was working on some code that compiled with vc6, eg.g

for(int i;i<x;);
if(i<j)
{// etc

which I rewrote to

int i = 0;
for(i = n;i<x;);
if(i<j)
{// etc

to make it more compliant, but strangely I got a
warning C4288: nonstandard extension used : 'i' : loop control variable
declared in the for-loop is used outside the for-loop scope; it
conflicts with the declaration in the outer scope

This is boggling my mind, because i is NOT declared in the for-loop. Any
ideas?

thanks,
max
Nov 17 '05 #1
2 1097
>I was working on some code that compiled with vc6, eg.g

for(int i;i<x;);
if(i<j)
{// etc

which I rewrote to

int i = 0;
for(i = n;i<x;);
if(i<j)
{// etc

to make it more compliant, but strangely I got a
warning C4288: nonstandard extension used : 'i' : loop control variable
declared in the for-loop is used outside the for-loop scope; it
conflicts with the declaration in the outer scope

This is boggling my mind, because i is NOT declared in the for-loop. Any
ideas?


Have you got a complete compilable snippet that illustrates the
problem?

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
Nov 17 '05 #2
Just check if 'i' is not re-declared in the for loop. Else add the compiler option /Zc:forScope which will tell that the standard C++ behavior of for loop to be followed in the program.

Balaji

"maxim khesin" wrote:
I was working on some code that compiled with vc6, eg.g

for(int i;i<x;);
if(i<j)
{// etc

which I rewrote to

int i = 0;
for(i = n;i<x;);
if(i<j)
{// etc

to make it more compliant, but strangely I got a
warning C4288: nonstandard extension used : 'i' : loop control variable
declared in the for-loop is used outside the for-loop scope; it
conflicts with the declaration in the outer scope

This is boggling my mind, because i is NOT declared in the for-loop. Any
ideas?

thanks,
max

Nov 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by matthias | last post: by
2 posts views Thread by cwdjr | last post: by
2 posts views Thread by russianthug | last post: by
2 posts views Thread by Charl | last post: by
10 posts views Thread by Sharrukin Amiri | last post: by
20 posts views Thread by SpreadTooThin | last post: by
3 posts views Thread by bsc_demos | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.