deterministic destruction support for managed types in VC++ 2005beta 1

  • Thread starter Slawomir Lisznianski
  • Start date
S

Slawomir Lisznianski

Do ref classes indeed support instantiation on the stack? Similarly, can
native classes be instantiated on gc heap?

When you try to have a ref class instance on the stack, you'll get:

R : cannot use this type here without a top-level '^'.

When you try to instantiate a native class using gcnew using Visual
Studio 2005 Beta 1, you'll get:

error C2726: 'gcnew' may only be used to create an object with managed type.

I was going through the C++/CLI Language Specification Working Draft
1.5, Jun, 2004, and nowhere I could find a clause that would make me
believe that managed types are allowed to go on the stack or native heap.

I've read articles, such as this one
http://www.codeguru.com/Csharp/.NET/net_general/visualstudionetadd-ins/article.php/c7405/

that makes all sorts of claims regarding support for deterministic
destruction for managed types. Where is it mentioned in the C++/CLI draft?

Regards,
Slawomir Lisznianski [ www.rhapsodia.org ]
 
C

Carl Daniel [VC++ MVP]

Slawomir said:
Do ref classes indeed support instantiation on the stack? Similarly,
can
native classes be instantiated on gc heap?

When you try to have a ref class instance on the stack, you'll get:

R : cannot use this type here without a top-level '^'.

When you try to instantiate a native class using gcnew using Visual
Studio 2005 Beta 1, you'll get:

error C2726: 'gcnew' may only be used to create an object with
managed type.

I was going through the C++/CLI Language Specification Working Draft
1.5, Jun, 2004, and nowhere I could find a clause that would make me
believe that managed types are allowed to go on the stack or native
heap.

I've read articles, such as this one
http://www.codeguru.com/Csharp/.NET/net_general/visualstudionetadd-ins/article.php/c7405/

that makes all sorts of claims regarding support for deterministic
destruction for managed types. Where is it mentioned in the C++/CLI
draft?

VC++ 2005 will support GC types on the stack, but that support is not in
Beta-1. I don't know about native types on the GC heap. I believe that's
in the long-term plan (complete unification of the GC/native type system),
but I'm not sure if it's in the 2005 compiler or not.

-cd
 
B

Brandon Bray [MSFT]

Carl said:
VC++ 2005 will support GC types on the stack, but that support is not in
Beta-1. I don't know about native types on the GC heap. I believe that's
in the long-term plan (complete unification of the GC/native type system),
but I'm not sure if it's in the 2005 compiler or not.

Unfortunately, creating native classes with gcnew did not make it into the
Visual C++ 2005 release. It's one of the top features for the next major
release of Visual C++.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top