C2360 compiler error on TFS build, but not on desktop

Posted by pdmaguire on Stack Overflow See other posts from Stack Overflow or by pdmaguire
Published on 2010-05-11T03:12:09Z Indexed on 2010/05/11 3:14 UTC
Read the original article Hit count: 271

Filed under:
|
|
|

A c++ 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?

© Stack Overflow or respective owner

Related posts about tfs

Related posts about msbuild