Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7944 Discussions

for statement variable scoping error

j_adair
Beginner
475 Views

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
475 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

0 Kudos
4 Replies
JenniferJ
Moderator
476 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
0 Kudos
j_adair
Beginner
475 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
0 Kudos
JenniferJ
Moderator
475 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

0 Kudos
jimdempseyatthecove
Honored Contributor III
475 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
0 Kudos
Reply