INFO: Misplaced __declspec Causes Error C2062, C2059, or C4 (117687)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 1.0
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 4.0
- Microsoft Visual C++, 32-bit Editions 5.0
- Microsoft Visual C++, 32-bit Editions 6.0
This article was previously published under Q117687 SUMMARY
Compiling a C or C++ source file that contains an incorrectly placed
__declspec keyword may cause the compiler to issue a warning or error
message. The possible messages and the version of the 32-bit compiler
generating them are listed below:
Source CL.EXE Version Error/Warning
C 8.xx error C2062: type 'int' unexpected
C++ 8.xx error C2059: syntax error :
'__declspec(Storage_Class_Attribute)'
C/C++ 9.xx error C2059: syntax error :
'__declspec(Storage_Class_Attribute)'
C 10.xx error C2059: syntax error : 'type'
C++ 10.xx warning C4230: anachronism used :
modifiers/qualifiers interspersed, qualifier ignored
where "Storage_Class_Attribute" is one of the following:
- thread
- naked
- dllimport
- dllexport
REFERENCES
For more information, search the online documentation included with Visual
C++, 32-bit Edition, on "__declspec," "thread," "naked," "dllimport,"
"dllexport," or "storage-class attributes." For an in-depth discussion of
these topics and more, see the "Programming Techniques" book in the Visual
C++, 32-bit Edition, documentation set.
Modification Type: | Major | Last Reviewed: | 12/2/2003 |
---|
Keywords: | kbCompiler kberrmsg kbinfo KB117687 |
---|
|