Community
cancel
Showing results for 
Search instead for 
Did you mean: 
j_adair
Beginner
82 Views

for statement variable scoping error

Jump to solution

Using the Intel C++ Compiler Professional for applications running on IA-32, Version 11.1, Build 20090511, I am encountering the for-scope error thus:

file.cpp(389): error: "i" has already been declared in the current scope

for (int i = 0; i < (foo->bar_count - 1); i += 2)

^

This should be acceptable with the ANSI standard, but nonetheless I am getting this error. If I recall correctly there is a compiler option that I can specify that will eliminate this error. However after browsing the Intel C++ compiler options via the website I still cannot find it.

Help?

Thanks!

0 Kudos
1 Solution
JenniferJ
Moderator
82 Views
You can use /Zc:forScope- to disable this checking.

Also I noticed that you're using an older 11.1, please upgrade to the latest 11.1.060 or at least 11.1.048. There is a bug in the original 11.1 release that will affect programs running on Windows 7.

Thanks,
Jennifer

View solution in original post

4 Replies
JenniferJ
Moderator
83 Views
You can use /Zc:forScope- to disable this checking.

Also I noticed that you're using an older 11.1, please upgrade to the latest 11.1.060 or at least 11.1.048. There is a bug in the original 11.1 release that will affect programs running on Windows 7.

Thanks,
Jennifer

View solution in original post

j_adair
Beginner
82 Views
Hi Jennifer,

Ok thank you so much for the reply. We'll look into the 11.1 bug, thanks for that heads up as well.

Is there a Linux/MacOS equivalent to the /Zc:forScope- option?

Thanks!

Jerry
JenniferJ
Moderator
82 Views

There's no matching Linux option for /Zc:forScope-. But try followings:
'-c99' option on Linux
'-stdc99' option on Linux
'-stdc9x' option on Linux

About the bug in earlier 11.1 pkg, see this article about it:

Jennifer

jimdempseyatthecove
Black Belt
82 Views
Or you can do this:

{ // hack scope for Intel V11.0.0 bug
for (int i = 0; i < (foo->bar_count - 1); i += 2)
{
...
}
} // end hack scope for Intel V11.0.0 bug
Reply