Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between Managed C++ and C++/CLI?

What is exactly the difference between the "old" Managed C++ and the "new" C++/CLI?

like image 960
Alon Gubkin Avatar asked Mar 14 '10 21:03

Alon Gubkin


People also ask

What is C++/CLI used for?

C++/CLI allows C++ programs to consume C# programs in C# DLLs. Here the #using keyword shows the compiler where the DLL is located for its compilation metadata. This simple example requires no data marshalling.

Is C++ CLI for managed?

Yes, C++/CLI has a very specific target usage, the language (and its compiler, most of all) makes it very easy to write code that needs to interop with unmanaged code. It has built-in support for marshaling between managed and unmanaged types.

Is C++ managed or unmanaged?

The C++ compiler actually uses two heaps, a managed an unmanaged one, and uses operator overloading on new to decide where to allocate memory when you create an instance with new.


1 Answers

Managed C++ is the version in VS2002 and VS2003. It had race conditions and other serious bugs, as well as being confusing. It's no longer supported.

In VS2005, Microsoft introduced C++/CLI, which has also been accepted as an ISO standard. It's also supported in VS2008 and the upcoming VS2010.

Both of them had the same goal, which is to create .NET assemblies using the C++ language. The syntax is different (C++/CLI managed code is a lot easier to differentiate from standard C++ at a glance) and C++/CLI also has syntax for .NET 2.0 features such as generics.

like image 140
Ben Voigt Avatar answered Oct 12 '22 12:10

Ben Voigt