FIX: LNK2001 Incorrectly Generated for Static Data Member (149784)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 4.0
This article was previously published under Q149784 SYMPTOMS
When 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.
CAUSE
Storage-class specifiers, such as __declspec(), are only necessary for
declarations. They are not needed (but are not wrong) otherwise.
RESOLUTION
Remove the storage-class specifier.
STATUS
Microsoft 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.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbbug kbCompiler kbCPPonly kbfix KB149784 |
---|
|