Compiling a VC++ 6.0 project with VC++ 7.1 problem: Error C2664 with CComPtr. Please help.
-
Hello dear COM experts, While trying to compile a VC++ 6.0 project with VC++ 7.1, I have got the following error : d:\TESTINGONLY\dbstudio\DSIFormat.h(58) : error C2664: '_com_ptr_t<_IIID>::_com_ptr_t(int)' : cannot convert parameter 1 from 'ATL::CComPtr' to 'int' with [ _IIID=_com_IIID ] and [ T=StdFormat::IStdDataFormatDisp ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called This error is caused by the following instanciation CComPtr m_fmtBinary; StdFormat::IStdDataFormatDisp is located in a .tlh file. I am a newbee with COM and I guess it is an interface generated by the compiler. Here is its definition struct __declspec(uuid("6c51b910-900b-11d0-9484-00a0c91110ed")) IStdDataFormatDisp : IDataFormatDisp { // // Property data // __declspec(property(get=GetType,put=PutType)) enum FormatType Type; __declspec(property(get=GetFormat,put=PutFormat)) _bstr_t Format; } It derives from struct __declspec(uuid("e675f3f0-91b5-11d0-9484-00a0c91110ed")) IDataFormatDisp : IDispatch {}; IDataFormatDisp does nothing so I wonder why not deriving IStdDataFormatDisp direcly from IDispatch:confused: Indeed the project works fine with visual c++ 6.0. I thank you very much for your help.
-
Hello dear COM experts, While trying to compile a VC++ 6.0 project with VC++ 7.1, I have got the following error : d:\TESTINGONLY\dbstudio\DSIFormat.h(58) : error C2664: '_com_ptr_t<_IIID>::_com_ptr_t(int)' : cannot convert parameter 1 from 'ATL::CComPtr' to 'int' with [ _IIID=_com_IIID ] and [ T=StdFormat::IStdDataFormatDisp ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called This error is caused by the following instanciation CComPtr m_fmtBinary; StdFormat::IStdDataFormatDisp is located in a .tlh file. I am a newbee with COM and I guess it is an interface generated by the compiler. Here is its definition struct __declspec(uuid("6c51b910-900b-11d0-9484-00a0c91110ed")) IStdDataFormatDisp : IDataFormatDisp { // // Property data // __declspec(property(get=GetType,put=PutType)) enum FormatType Type; __declspec(property(get=GetFormat,put=PutFormat)) _bstr_t Format; } It derives from struct __declspec(uuid("e675f3f0-91b5-11d0-9484-00a0c91110ed")) IDataFormatDisp : IDispatch {}; IDataFormatDisp does nothing so I wonder why not deriving IStdDataFormatDisp direcly from IDispatch:confused: Indeed the project works fine with visual c++ 6.0. I thank you very much for your help.
.tlh
files are generated by the compiler when it encounters a#import
directive. The exact behaviour of what the compiler does depends on the options to that directive. The compiler has a COM support library which already supplies smart pointers, so use of ATL'sCComPtr
is unnecessary. See the definitions of_com_ptr_t
. If you don't want the compiler to generate smart pointer wrappers, specifyno_smart_pointers
in the#import
directive. I would generally try to avoid reusing the.tlh
file from a previous compilation session, particularly when moving between compilers. The underlying compiler support classes may have changed. That's probably what's happened here.DoEvents: Generating unexpected recursion since 1991