FIX: Unexpected LNK2020 unresolved token error during build (326813)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition

This article was previously published under Q326813

SYMPTOMS

During the build of a Visual C++ project, you may incorrectly receive the following error message:
LINK : error LNK2020: unresolved token (0A000008) CreateM
LINK : fatal error LNK1120: 1 unresolved externals
Note The actual token number and name ('0A000008' and 'CreateM' respectively in this sample error message) vary from project to project but the linker errors (LNK2020 and LNK1120) are consistent. There are circumstances in which these errors message are correct. For more information, search the Visual C++ documentation for these linker errors.

CAUSE

Because of a bug in the C++ compiler, some programming constructs that involve variable argument lists (...) can create this problem. For example, you receive the error message that appears in the "Symptoms" section when you compile and then link the following code samples:
class M 
{ 
public: 
M() {} 
}; 
M CreateM(int i, ...) 
{ 
return(M()); 
} 
void Test() 
{ 
CreateM(1, 2, 3, 4); 
} 

				
#include <string>
std::string FormatString(char* lpszFormat, ...)
{
return(std::string());
}
void test()
{
FormatString("hello", 1);
}
				

RESOLUTION

Service pack information

To resolve this problem, obtain the latest service pack for Microsoft Visual Studio .NET. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

837234 List of bugs that are fixed in Visual Studio .NET 2002 Service Pack 1

Hotfix information

The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
   Date          Time    Version       Size        File name
   ---------------------------------------------------------
   24-JUL-2002   01:41   13.0.9521.0   2,105,344   c1xx.dll
				

Note After you install the hotfix, you must fully rebuild any affected projects to repair the error.

WORKAROUND

To work around this problem, do not use the variable argument list (...), or change the return type of the function to be a simpler type (not a string or class, as appear in the sample code in the "Cause" section).

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
This problem was first corrected in Visual Studio .NET 2002 Service Pack 1.

Modification Type:MinorLast Reviewed:9/27/2005
Keywords:kbHotfixServer kbQFE kbvs2002sp1sweep kbvs2002sp1fix kbbug kbfix kbQFE KB326813