BUG: You receive C2146 and C2501 compiler errors in the .tlh file or the .tli file when you use the #import statement to create smart pointers for an ActiveX server (224610)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q224610 SYMPTOMS When using #import to create smart pointers for an ActiveX
server, you may see C2146 and C2501 compiler errors in either of the .tlh or
.tli files. This will happen if the type library used IFontDisp and
IPictureDisp interfaces. circ3.tlh(54) : error
C2146: syntax error : missing ';' before identifier 'Font' circ3.tlh(54) :
error C2501: 'FontPtr' : missing storage-class or type specifiers
CAUSE IFontDisp and IPictureDisp are just typedefs for the
interfaces Font and Picture respectively. The header file Comdef.h incorrectly
declares smart pointer classes for the synonyms IFontDisp and IPictureDisp
rather than the actual interface types Font and Picture. This is what results
in the compilation error. RESOLUTION In order to get around this error, #import the typelib
Stdole2.tlb prior to importing the ActiveX servers typelib and make sure that
they exist in the same namespace. For example, if you were using the CIRC3 MFC
ActiveX control, employ the following code as the workaround:
#import "c:\winnt\system32\stdole2.tlb" rename_namespace("New") exclude("GUID", "DISPPARAMS", "EXCEPINFO", \
"OLE_XPOS_PIXELS", "OLE_YPOS_PIXELS", "OLE_XSIZE_PIXELS", "OLE_YSIZE_PIXELS", "OLE_XPOS_HIMETRIC", \
"OLE_YPOS_HIMETRIC", "OLE_XSIZE_HIMETRIC", "OLE_YSIZE_HIMETRIC", "OLE_XPOS_CONTAINER", \
"OLE_YPOS_CONTAINER", "OLE_XSIZE_CONTAINER", "OLE_YSIZE_CONTAINER", "OLE_HANDLE", "OLE_OPTEXCLUSIVE", \
"OLE_CANCELBOOL", "OLE_ENABLEDEFAULTBOOL", "FONTSIZE", "OLE_COLOR")
#import "debug\circ3.tlb" rename_namespace("New")
using namespace New;
STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
REFERENCES185284 FIX: #import Does not Correctly Handle GUID Parameters
Modification Type: | Major | Last Reviewed: | 9/8/2005 |
---|
Keywords: | kbtshoot kbAutomation kbbug kbpending kbSmartPtr KB224610 kbAudDeveloper |
---|
|