cmroanirgo

Hopefully this issue hasn't been posted multiple times in the past (apologies if it has).

I have found that if I declare a templated CLI class without instantiating it, I get linker errors:

template <typename T >

ref struct MyTemplate

{

~MyTemplate() { }

!MyTemplate() { }

};

int main(array<System:: String ^> ^args)

{

MyTemplate<int>^ xyz = nullptr;

// remove any comment below and linker won't have an error

// xyz = gcnew MyTemplate<int>();

// delete xyz;

return 0;

}

Has anyone else noticed this I was driving myself crazy looking for a fault in my code when there was none!!!

PS: The linker errors are:

error LNK2020: unresolved token (06000002) MyTemplate<int>:: Dispose

error LNK2020: unresolved token (06000003) MyTemplate<int>:: Dispose

error LNK2020: unresolved token (06000004) MyTemplate<int>:: Finalize



Re: Visual C++ Language linker errors due to compiler bug

scor7910

Hi cmroanirgo~

Reference this page.

http://msdn2.microsoft.com/en-us/library/b57tw91b(vs.80).aspx

It's interesting. '')






Re: Visual C++ Language linker errors due to compiler bug

cmroanirgo

Thanks scor7910,

I find it interesting that MS has noted this issue in the most recent version of MSDN. The version of MSDN that I looked up for LNK2020 was the version that came with VS2005 CD and it does NOT include that snippet of information.

Hence, one can only surmise that this is indeed an 'issue' that was found after shipping the product and that they have down-played by now indicating that it is expected behavior.