• 0

C++ vs. C++/CLI


Question

6 answers to this question

Recommended Posts

  • 0

C++ is an ISO standard (current version is C++11), C++/CLI is a .NET language derived from standard C++ owned by Microsoft. Opposed to (most) other .NET languages, C++/CLI can access both native and managed resources, whereas C++ is purely for native development. C++/CLI contains quite some extensions to the syntax - for example a way to allocate and handle "managed" objects,? - and is therefor locked into .NET (not quite sure if there exists a free C++/CLI compiler, wouldn't bet on it). C++/CLI is actually a re-envisioning from the "Managed Extensions for C++" with a different syntax, because the one of the managed extensions was just a pure nightmare.

Link to comment
Share on other sites

  • 0

They are separate languages.

C++ is a C-based language designed by Bjarne Stroustrup that compiles to native code and is widely supported across essentially all operating systems. Its fine-grained level of control and large level of support is what makes it so important even today.

C++/CLI is a C++-based language designed by Microsoft to allow development of .net components in a language as close to C++ as possible. It's a superset: valid C++ is valid C++/CLI, but valid C++/CLI isn't necessarily valid C++. C++/CLI is of a relatively limited use, mainly for developing mixed .net/native applications or creating interfaces between native and managed components. It combines all the complexity of C++ and the complexity of .net together, so you'd better have a solid grasp on both before even considering learning this.

Link to comment
Share on other sites

  • 0

i wouldn't say that valid C++ is valid C++/CLI, there are some differences in semantics? First example that comes to mind is "nullptr"?

eh?

Link to comment
Share on other sites

  • 0

i wouldn't say that valid C++ is valid C++/CLI, there are some differences in semantics? First example that comes to mind is "nullptr"?

C++11 has adopted nullptr as a null pointer constant, also enum class from C++/CLI has been adopted in C++11.

Link to comment
Share on other sites

  • 0

C++11 has adopted nullptr as a null pointer constant, also enum class from C++/CLI has been adopted in C++11.

C++11 and C++/CLI nullptr have different behaviours (C++11 nullptr has a type, the other doesn't), which causes problems and has led to the need for __nullptr in C++/CLI

The C++11 standard introduced nullptr as the thing it was replacing (NULL) had plenty of issues, mostly due to calling functions like the following and not necessarily because C++/CLI had it.

void f(int);
void f(char *);

f(NULL); // calls f(int)
f(nullptr); // calls f(char *)

Link to comment
Share on other sites

This topic is now closed to further replies.