So I've inherited some code that's about as old as me and I'm tasked with maintaining it. The code was written using Visual C++ 6, so it's not modern by any stretch of the imagination.
Anyway, I decided to try and upgrade the solution (or I guess workspace as Microsoft called it back then) so that I can use it with Visual Studio 2013 and use a somewhat modern IDE (I think I'd rather use Emacs or plain-old notepad over VC++ 6). After having changed the character set for the MFC library, I'm getting a whole bunch of undeclared identifier
errors (on the order of about 1100 errors). A LOT of them seem to stem from a temporary variable scoping issue, that has me wondering how on earth this code was allowed to compile previously. I'm seeing a lot of stuff like this:
void MyClass::MyFunc()
{
for(int i=0;i<56;i++)
{
// do some stuff
}
// command hardware
for(i=0;i<m_pinfo->vc_num;i++)
{
// do some more stuff
}
}
Miraculously, this code compiles just fine in VC++ 6, but (thankfully) not in VS 2013. Notice how the variable i
was declared within the scope of the first for
loop, but it was then used again in the second for
loop. This kind of code is littered throughout the program.
Using VC++ 6's Goto Definition tool, it's telling me that there's an ambiguity between the variable i
(but it still compiles!) and several seemingly unrelated variables and parameters called 'i' that are in separate .cpp files all-together, some of them defined in structures even.
What could be going on here? For all intents and purposes, I cannot see how this code is allowed to compile in VC++6.