LNK2022: metadata operation failed when using 3 lambda expressions

With the following class in one c ++ / cli project:

class __declspec(dllimport) MyClass
{
public:
    void Test(std::function<void()> operation)
    {
        operation();
    }
}

      

And the caller in another C ++ / cli project:

myClass.Test([](){});
myClass.Test([](){});
myClass.Test([](){});

      

I am getting the following error (twice):

LNK2022: metadata failure (8013118D): Inconsistent layout information in duplicate types (std.tr1._Callable_obj <anonymous namespace '::, 0>): (0x02000490).

I don't get the error when called Test

only twice!

myClass.Test([](){});
myClass.Test([](){});

//COMPILES FINE!
//myClass.Test([](){});

      

I tried to disable the managed incremental building according to "LNK2022: Metadata Failure" driving me crazy . However, mistakes do occur.

I am building VS2013 but using the Visual Studio 2010 (v100) Platform Toolkit.

+3


source to share





All Articles