A c++/cli code snippet similar to the code below caused our TFS build to fail with a C2360 compiler error.
switch (i)
{
case 0 :
for each (int n in a)
System::Console::WriteLine(n.ToString());
break;
case 1 :
System::Console::WriteLine("n is not in scope here");
break;
}
This is fixed by using {} brackets within the body of case 0, as below:
switch (i)
{
case 0 :
{
for each (int n in a)
System::Console::WriteLine(n.ToString());
}
break;
case 1 :
System::Console::WriteLine("n is not in scope here");
break;
}
The developer had successfully compiled the code on their desktop before committing the changes.
A cursory look at versions of things like compilers, Visual Studio etc on the server and desktop suggest they are the same.
The source code is the same, obviously.
What is the difference between a desktop build and TFS build that would smother a compiler error like this?