TT (Tom Tempelaere) said:
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