Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

compiler problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DR - 02 Sep 2005 22:36 GMT
void a()
{
for (int i = 0; i <100; i++)
{
...
}
...
for (i = 0; i <100; i++) <-- ERROR
{
...
}
}

The VC++ 2005 compilers says "i undeclared identifer". Why?
sashan - 02 Sep 2005 22:52 GMT
i is out of scope after the end of the first for loop. There was a time
when some compilers would allow i to be in scope after the 1st for loop
had ended but the C++ standard (see section 6.5.3) does not allow this
behaviour any more. You can tell the compiler using /Ze that you want i
to be in scope after the end of the loop. Personally I would change my
code so that it was standard compliant.

--
sashan
http://sashang.orcon.net.nz/index.htm
Jonathan Caves - 03 Sep 2005 01:44 GMT
>i is out of scope after the end of the first for loop. There was a time
> when some compilers would allow i to be in scope after the 1st for loop
[quoted text clipped - 6 lines]
> sashan
> http://sashang.orcon.net.nz/index.htm

In Visual C++ 2005 the option to revert back to the old non-conformant
behavior is:

/Zc:forScope-
Signature

Jonathan Caves
Visual C++ Compiler Team

DR - 03 Sep 2005 04:21 GMT
> In Visual C++ 2005 the option to revert back to the old non-conformant
> behavior is:
>
> /Zc:forScope-

I figured that out.

I'll report a bug:
The /W0 option seams to be ignored by the VC++2005Exp compiler . I still get
warnings.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.