C ++ / CLI:我为什么要使用它? [英] C++/CLI: why should I use it?

查看:398
本文介绍了C ++ / CLI:我为什么要使用它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是pretty的熟悉C ++,所以我认为学习.NET及其所有衍生物(特别是C#)。

I'm pretty familiar with C++, so I considered learning .NET and all its derivatives (especially C#).

一路上我碰到了C ++ / CLI的方式,我想知道是否有该语言的任何特定用途?难道仅仅是假设是一个中间语言从本地C ++转换为C#?

Along the way I bumped into C++/CLI, and I want to know if there is any specific use for that language? Is it just suppose to be a intermediate language for transforming from native C++ to C#?

这突然出现到我头上的另一个问题是,为何仍有.NET Framework中这么多的编程语言? (VB,C ++ / CLI,C#...)

Another question that popped to my head is why are there still so many programming languages in .NET framework? (VB, C++/CLI, C#...)

推荐答案

是的,C ++ / CLI有一个非常具体的目标使用,语言(和它的编译器,最重要的),使得它很容易写code需要互操作与非托管code。它内置了支持托管和非托管类型之间封送处理。它曾经被称为IJW(它只是工作),现在被称为C ++ Interop程序。其他语言需要使用的P / Invoke封送处理可以是效率低下,有限的能力相比,现在的C ++ / CLI可以做的。

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. It used to be called IJW (It Just Works), nowadays called C++ Interop. Other languages need to use the P/Invoke marshaller which can be inefficient and has limited capabilities compared to what C++/CLI can do.

在.NET框架包含了写在C ++ / CLI,特别是在System.Data这和WPF的presentationCore code。如果没有非托管互操作需要或不具有与传统code的基础工作,那么有什么理由选择C ++ / CLI。 C#或VB.NET是更好的选择。 C ++ / CLI的功能集得到了冻结在2005年左右,它有一个更近的增加像lambda表达式或LINQ语法的支持。也不对IDE支持许多在C​​#和VB.NET集成开发环境提供了花里胡哨的。值得注意的是,VS2010最初将不出货为C ++ / CLI IntelliSense支持。一个吻,死亡存在的一点。

The .NET framework contains code that was written in C++/CLI, notably in System.Data and WPF's PresentationCore. If you don't have unmanaged interop needs or don't have to work with a legacy code base then there are few reasons to select C++/CLI. C# or VB.NET are the better choices. C++/CLI's feature set got frozen around 2005, it has no support for more recent additions like lambdas or Linq syntax. Nor does the IDE support many of the bells and whistles available in the C# and VB.NET IDEs. Notable is that VS2010 will initially ship without IntelliSense support for C++/CLI. A bit of a kiss-of-death there.

更新:复兴VS2012,智能感知的支持又回来了。不中的C ++ / CX,它简化了编写C ++编写的WinRT应用程序语言扩展最少的感谢。它的语法非常类似于C ++ / CLI。 Windows窗体被拆除的项目模板,设计师却仍然有效。新的调试引擎VS2012不支持C ++ / CLI,你必须把在工具中的管理兼容性模式选项+选项,调试,一般。

UPDATE: revived in VS2012, IntelliSense support is back. Not in the least thanks to C++/CX, a language extension that simplifies writing WinRT apps in C++. Its syntax is very similar to C++/CLI. The Windows Forms project templates were removed, the designer however still works. The new debugging engine in VS2012 doesn't support C++/CLI, you have to turn on the "Managed Compatibility Mode" option in Tools + Options, Debugging, General.

这篇关于C ++ / CLI:我为什么要使用它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆