473,480 Members | 2,271 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

When to add __gc decorator

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,
--
Tom Tempelaere.
Nov 17 '05 #1
5 1087
"TT (Tom Tempelaere)" <_|\|_0$P@|/\|titi____AThotmailD.Tcom|/\|@P$0_|\|_>
wrote in message news:DB**********************************@microsof t.com...
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
Nov 17 '05 #2
Thank you William, I understand now.

Tom Tempelaere.
Nov 17 '05 #3
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.

Nov 17 '05 #4
_B
On Tue, 8 Mar 2005 11:03:51 -0500, "William DePalo [MVP VC++]"
<wi***********@mvps.org> wrote:
.... 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?

Nov 17 '05 #5
"_B" <_B@nomail.org> wrote in message
news:gt********************************@4ax.com...
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
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?


This is an introduction:

http://msdn.microsoft.com/msdnmag/is...C/default.aspx

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

http://msdn.microsoft.com/library/de...TransGuide.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
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

41
2804
by: John Marshall | last post by:
How about the following, which I am almost positive has not been suggested: ----- class Klass: def __init__(self, name): self.name = name deco meth0: staticmethod def meth0(x):
30
2462
by: Ron_Adam | last post by:
I was having some difficulty figuring out just what was going on with decorators. So after a considerable amount of experimenting I was able to take one apart in a way. It required me to take a...
3
2406
by: Ron_Adam | last post by:
Ok... it's works! :) So what do you think? Look at the last stacked example, it process the preprocess's first in forward order, then does the postprocess's in reverse order. Which might be...
6
1378
by: Michele Simionato | last post by:
could ildg wrote: > I think decorator is a function which return a function, is this right? > e.g. The decorator below if from http://www.python.org/peps/pep-0318.html#id1. > > def...
2
2545
by: microsoft | last post by:
Hi All, I am fairly new to Managed C++ extensions. I started trying to implement a interface defined in a C# project, in C++. The problem was with passing value arrays from c# to c++. I found...
5
1554
by: kchui | last post by:
I have a C# interface as: public interface IBar{ void TestParam(ref StringCollection a, ref int b); } And I need to implment it in Managed C++, and I try to implement it as: public __gc...
5
1799
by: Doug | last post by:
I am looking at using the decorator pattern to create a rudimentary stored proc generator but am unsure about something. For each class that identifies a part of the stored proc, what if I want to...
0
927
by: craig.conboy | last post by:
Using MC++ .Net 2.0, with the CLR Profiler (from Microsoft) I am seeing that 3 blocks of memory, each ~48MB in size, being allocated by some code that initializes a managed array. It is a jagged...
4
2449
by: thomas.karolski | last post by:
Hi, I would like to create a Decorator metaclass, which automatically turns a class which inherits from the "Decorator" type into a decorator. A decorator in this case, is simply a class which...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4787
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.