Jump to content
  • Advertisement
Sign in to follow this  
CodaKiller

CComPtr without ATL?

This topic is 3346 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I think _com_ptr_t should do the trick but I can't get it to work, I used comsuppw.lib and comdef.h to include it in to my project but when I try to use it like CComPtr it gives me a long list of errors. Here is all I tried to do with it:
_com_ptr_t<ISpRecoContext> rc;



how do I use _com_ptr_t?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Codeka
That's pretty much it, what errors do you get?


Quote:

1>------ Build started: Project: Ether, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\comip.h(66) : error C2039: 'Interface' : is not a member of 'ISpRecoContext'
1> C:\Program Files\Microsoft SDKs\Windows\v6.0A\include\sapi.h(9038) : see declaration of 'ISpRecoContext'
1> .\Main.cpp(3339) : see reference to class template instantiation '_com_ptr_t<_IIID>' being compiled
1> with
1> [
1> _IIID=ISpRecoContext
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(1598) : see reference to function template instantiation 'void std::_Debug_range2<_InIt>(_RanIt,_RanIt,const wchar_t *,unsigned int,std::random_access_iterator_tag)' being compiled
1> with
1> [
1> _InIt=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>,
1> _RanIt=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\memory(125) : see reference to function template instantiation 'void std::_Debug_range<_InIt>(_InIt,_InIt,const wchar_t *,unsigned int)' being compiled
1> with
1> [
1> _InIt=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\memory(822) : see reference to function template instantiation '_FwdIt std::_Uninit_copy<std::_Vector_const_iterator<_Ty,_Alloc>,_FwdIt,_Alloc>(_InIt,_InIt,_FwdIt,_Alloc &,std::_Nonscalar_ptr_iterator_tag,std::_Range_checked_iterator_tag)' being compiled
1> with
1> [
1> _FwdIt=luabind::detail::construct_rep::overload_t *,
1> _Ty=luabind::detail::construct_rep::overload_t,
1> _Alloc=std::allocator<luabind::detail::construct_rep::overload_t>,
1> _InIt=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector(1141) : see reference to function template instantiation '_FwdIt stdext::unchecked_uninitialized_copy<_Iter,luabind::detail::construct_rep::overload_t*,std::allocator<_Ty>>(_InIt,_InIt,_FwdIt,_Alloc &)' being compiled
1> with
1> [
1> _FwdIt=luabind::detail::construct_rep::overload_t *,
1> _Iter=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>,
1> _Ty=luabind::detail::construct_rep::overload_t,
1> _InIt=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>,
1> _Alloc=std::allocator<luabind::detail::construct_rep::overload_t>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector(503) : see reference to function template instantiation 'luabind::detail::construct_rep::overload_t *std::vector<_Ty>::_Ucopy<std::_Vector_const_iterator<_Ty,_Alloc>>(_Iter,_Iter,luabind::detail::construct_rep::overload_t *)' being compiled
1> with
1> [
1> _Ty=luabind::detail::construct_rep::overload_t,
1> _Alloc=std::allocator<luabind::detail::construct_rep::overload_t>,
1> _Iter=std::_Vector_const_iterator<luabind::detail::construct_rep::overload_t,std::allocator<luabind::detail::construct_rep::overload_t>>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vector(498) : while compiling class template member function 'std::vector<_Ty>::vector(const std::vector<_Ty> &)'
1> with
1> [
1> _Ty=luabind::detail::construct_rep::overload_t
1> ]
1> C:\Program Files (x86)\Luabind\0.8.1\include\luabind/detail/construct_rep.hpp(81) : see reference to class template instantiation 'std::vector<_Ty>' being compiled
1> with
1> [
1> _Ty=luabind::detail::construct_rep::overload_t
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\comip.h(66) : error C2146: syntax error : missing ';' before identifier 'Interface'
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\comip.h(66) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\comip.h(66) : error C2602: '_com_ptr_t<_IIID>::Interface' is not a member of a base class of '_com_ptr_t<_IIID>'
1> with
1> [
1> _IIID=ISpRecoContext
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\comip.h(66) : see declaration of '_com_ptr_t<_IIID>::Interface'
1> with
1> [
1> _IIID=ISpRecoContext
1> ]
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\comip.h(66) : error C2868: '_com_ptr_t<_IIID>::Interface' : illegal syntax for using-declaration; expected qualified-name
1> with
1> [
1> _IIID=ISpRecoContext
1> ]
1>Build log was saved at "file://c:\Users\Steven\Desktop\Unbound Engine 0.5.0a\Debug\BuildLog.htm"
1>Ether - 5 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


Is comdef.h the right header?

Share this post


Link to post
Share on other sites
Oops, actually it looks like I was wrong about how you use _com_ptr_t. Turns out you need to use it like this:

_com_ptr_t< _com_IIID<ISpRecoContext, uuidof(ISpRecoContext)> > rc;

A simpler route is to use the _COM_SMARTPTR_TYPEDEF macro, like so:

_COM_SMARTPTR_TYPEDEF(ISpRecoContext, uuidof(ISpRecoContext));

// later...

ISpRecoContextPtr rc;

Depending on how you imported the type library into your project, the compiler might've already automatically generated that typedef.

Share this post


Link to post
Share on other sites
Quote:
Original post by Codeka
Oops, actually it looks like I was wrong about how you use _com_ptr_t. Turns out you need to use it like this:

*** Source Snippet Removed ***
A simpler route is to use the _COM_SMARTPTR_TYPEDEF macro, like so:

*** Source Snippet Removed ***
Depending on how you imported the type library into your project, the compiler might've already automatically generated that typedef.


Thank you very much! It works perfect!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!