Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
CComPtr vs. _COM_SMARTPTR_TYPEDEF macro
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Back 9  
View profile  
 More options Apr 2 2008, 5:59 pm
Newsgroups: microsoft.public.win32.programmer.directx.video
From: Back 9 <Ba...@discussions.microsoft.com>
Date: Wed, 2 Apr 2008 14:59:01 -0700
Local: Wed, Apr 2 2008 5:59 pm
Subject: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro
Hello,

Some people in my group say that using _COM_SMARTPTR_TYPEDEF macro is much
safer than using CComPtr.
I am just wondering how come it is true.
What is the strenths to use the macro over CComPtr?

Back9


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
The March Hare [MVP]  
View profile  
 More options Apr 2 2008, 6:07 pm
Newsgroups: microsoft.public.win32.programmer.directx.video
From: "The March Hare [MVP]" <themarchh...@alice.in.wonderland>
Date: Wed, 2 Apr 2008 16:07:27 -0600
Local: Wed, Apr 2 2008 6:07 pm
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro

On Wed, 2 Apr 2008 14:59:01 -0700, Back 9 wrote:
> Some people in my group say that using _COM_SMARTPTR_TYPEDEF macro is much
> safer than using CComPtr.

Why do they say that?  I have not heard any problems with safety with
CComPtr.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli  
View profile  
 More options Apr 2 2008, 6:34 pm
Newsgroups: microsoft.public.win32.programmer.directx.video
From: "Alessandro Angeli" <nob...@nowhere.in.the.net>
Date: Wed, 2 Apr 2008 18:34:04 -0400
Local: Wed, Apr 2 2008 6:34 pm
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro
From: "Back 9"

> Some people in my group say that using
> _COM_SMARTPTR_TYPEDEF macro is much safer than using
> CComPtr.
> I am just wondering how come it is true.
> What is the strenths to use the macro over CComPtr?

None? The macro expands to a typedef that uses MSVC's
_com_ptr_t template while CComPtr is ATL's implementation of
a smart pointer. Using the macro is a time-safer when you
use MSVC's smart pointers, especially when you need to
declare several variables of the same type, since _com_ptr_t
has a nightmarish syntax. But that doesn't make it safer
than CComPtr, which is a completely separate (and simpler)
implementation.

_com_ptr_t throws _com_error while CComPtr I think throws
CAtlException.

_com_ptr_t calls QI while CComPtr doesn't (but CComQIPtr
does).

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
The March Hare [MVP]  
View profile  
 More options Apr 2 2008, 7:02 pm
Newsgroups: microsoft.public.win32.programmer.directx.video
From: "The March Hare [MVP]" <themarchh...@alice.in.wonderland>
Date: Wed, 2 Apr 2008 17:02:37 -0600
Local: Wed, Apr 2 2008 7:02 pm
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro

On Wed, 2 Apr 2008 18:34:04 -0400, Alessandro Angeli wrote:
>  CComPtr is ATL's implementation of
> a smart pointer.

I think this is the reason some people, like G., prefer the macro.  They
don't want to introduce the ATL dependency on client's projects.  I don't
think it has to do with safety.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alessandro Angeli  
View profile  
 More options Apr 2 2008, 9:06 pm
Newsgroups: microsoft.public.win32.programmer.directx.video
From: "Alessandro Angeli" <nob...@nowhere.in.the.net>
Date: Wed, 2 Apr 2008 21:06:36 -0400
Local: Wed, Apr 2 2008 9:06 pm
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro
From: "The March Hare [MVP]"

> I think this is the reason some people, like G., prefer
> the macro.  They don't want to introduce the ATL
> dependency on client's projects.  I don't think it has to
> do with safety.

It's not like _com_ptr_t is plain ANSI C++ either, since it
is an MSVC++ extension of the standard library. To be "pure"
you need to bring along your own smart pointer template or
not use smart pointers. I advocate the latter, but I am a
minority :-)

--
// Alessandro Angeli
// MVP :: DirectShow / MediaFoundation
// mvpnews at riseoftheants dot com
// http://www.riseoftheants.com/mmx/faq.htm


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Back 9  
View profile  
 More options Apr 3 2008, 8:37 am
Newsgroups: microsoft.public.win32.programmer.directx.video
From: Back 9 <Ba...@discussions.microsoft.com>
Date: Thu, 3 Apr 2008 05:37:02 -0700
Local: Thurs, Apr 3 2008 8:37 am
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro
Then is there any memory leak issue with CComPtr that I should be aware of?
They say there is well-known issue of CComPtr. Unfortunately they could not
search the article on the web.

Thank,
Back9

"The March Hare [MVP]" wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
The March Hare [MVP]  
View profile  
 More options Apr 3 2008, 10:04 am
Newsgroups: microsoft.public.win32.programmer.directx.video
From: "The March Hare [MVP]" <themarchh...@alice.in.wonderland>
Date: Thu, 3 Apr 2008 08:04:31 -0600
Local: Thurs, Apr 3 2008 10:04 am
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro

On Thu, 3 Apr 2008 05:37:02 -0700, Back 9 wrote:
> Then is there any memory leak issue with CComPtr that I should be aware of?

Not that I am aware of.  I've been using them in my app for over six years
and haven't seen one.

> They say there is well-known issue of CComPtr. Unfortunately they could not
> search the article on the web.

I did a search and didn't see anything about memory leaks with CComPtr.

--
Please read this before replying:
1. Dshow & posting help:  http://tmhare.mvps.org/help.htm
2. Trim & respond inline (please don't top post or snip everything)
3. Benefit others:  follow up if you are helped or you found a solution


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Geraint Davies  
View profile  
 More options Apr 11 2008, 4:45 am
Newsgroups: microsoft.public.win32.programmer.directx.video
From: Geraint Davies <gerai...@gdcl.co.uk>
Date: Fri, 11 Apr 2008 09:45:49 +0100
Local: Fri, Apr 11 2008 4:45 am
Subject: Re: CComPtr vs. _COM_SMARTPTR_TYPEDEF macro
On Wed, 2 Apr 2008 17:02:37 -0600, "The March Hare [MVP]"

<themarchh...@alice.in.wonderland> wrote:
>I think this is the reason some people, like G., prefer the macro.  They
>don't want to introduce the ATL dependency on client's projects.  I don't
>think it has to do with safety.

[sorry -- bit behind with replying]

Yes, that and the behaviour is slightly different. The macro version
releases the object if you take the address. This sounds like a
hideous side-effect behaviour, but in fact it works just fine
        pSomething->ReturnMeAPointer(&pMySmartPtr);
If the smart pointer was not null before the call, ATL will assert but
the MSVC macro will release the pointer.

There's also a difference in the null testing which works the other
way.

G


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google