Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Compiling a VC++ 6.0 project with VC++ 7.1 problem: Error C2664 with CComPtr. Please help.

Compiling a VC++ 6.0 project with VC++ 7.1 problem: Error C2664 with CComPtr. Please help.

Scheduled Pinned Locked Moved COM
c++helpcom
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arris74
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • A Arris74

      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.

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      .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's CComPtr is unnecessary. See the definitions of _com_ptr_t. If you don't want the compiler to generate smart pointer wrappers, specify no_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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups