Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2005

Tip: Looking for answers? Try searching our database.

When to add __gc decorator

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TT (Tom Tempelaere) - 08 Mar 2005 13:19 GMT
Hey everyone,

If I am writing a .NET library using managed C++, when exactly do I have to
decorate a pointer with the __gc decorator?

Thanks,
Signature

Tom Tempelaere.

William DePalo [MVP VC++] - 08 Mar 2005 16:03 GMT
> If I am writing a .NET library using managed C++, when exactly do I have
> to
> decorate a pointer with the __gc decorator?

Well, pointers to managed objects are always __gc. So mostly, you don't have
to be explicit where you point to managed objects though it doesn't hurt.

Suppose though, that you have a managed class and that that managed class
has a member which has an unmanaged type - say integer. If you needed a
pointer to that integer then you'd need to mark the pointer as __gc. That's
because that ordinary integer is set on the managed heap and it can move out
from under you.

I hope this helps. I had hoped to come up with a more definitive, less
annecdotal explanation for you. I scanned the book "Essential Guide to
Managed Extensions for C++" hoping to find some advice from on high that I
could quote. What there is in the book is a whole _chapter_ on the topic.
I'd recommend the book, but depending on your release schedule, you might
want to wait for a book on C++/CLI which supplants MC++ in VS.Net 2005

Regards,
Will
TT (Tom Tempelaere) - 08 Mar 2005 16:25 GMT
Thank you William, I understand now.

Tom Tempelaere.
ismailp - 08 Mar 2005 22:13 GMT
you may need to use __gc on managed arrays, too.

i'd also recommend the same thing; wait for C++/CLI. you can get its
beta1 or latest ctp and enjoy using new language. there is no __gc in
C++/CLI.
_B - 07 Jun 2005 08:10 GMT
>.... depending on your release schedule, you might
>want to wait for a book on C++/CLI which supplants MC++ in VS.Net 2005
>
>Regards,
>Will

I had just posted a query about books on C++/CLI.  Looks like you just
answered it.  I'm surprised that no one got the jump on the 2005
compiler release.

Well, in the absence of a book, are there any good web-based
references on the subject?
William DePalo [MVP VC++] - 07 Jun 2005 15:09 GMT
> On Tue, 8 Mar 2005 11:03:51 -0500, "William DePalo [MVP VC++]"
> I had just posted a query about books on C++/CLI.  Looks like you just
[quoted text clipped - 3 lines]
> Well, in the absence of a book, are there any good web-based
> references on the subject?

This is an introduction:

http://msdn.microsoft.com/msdnmag/issues/05/02/PureC/default.aspx

This details the differences between MC++ and C++/CLI:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/Tra
nsGuide.asp


They should get you started. You can try googling for more, perhaps
searching for articles written by Lippman or ones on "C++/CLI"

Regards,
Will

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.