The information in this article applies to:
SYMPTOMSWhen declaring static members of C++ classes, you must initialize the static data member. Otherwise the linker generates an unresolved external error message. Visual C++ 4.0 incorrectly generates such an unresolved external error message if a storage-class specifier (such as __declspec(X)) is used on the initialization line of a static data member. CAUSEStorage-class specifiers, such as __declspec(), are only necessary for declarations. They are not needed (but are not wrong) otherwise. RESOLUTIONRemove the storage-class specifier. STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem has been corrected in Microsoft Visual C++ version 4.1. MORE INFORMATIONEarlier versions of Visual C++ generated the following error when a storage- class specifier is used on the initialization line: where 'line' is the line of code where the initialization takes place, and 'idata' is the name of the static data member. Visual C++ no longer generates the C2720 error (correctly so). The following sample code demonstrates the problem. Sample Code
Additional query words: 4.00 lnk2001 lnk1120 L2029 unresolved external LINK
Keywords : kbCompiler kbCPPonly kbVC |
Last Reviewed: September 10, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |