What is CLI/C++ exactly? How does it differ from 'normal' c++?

醉酒当歌 提交于 2019-12-01 00:14:16

问题


Let me clarify what I mean by 'normal' C++ first- I'm currently reading Walter Savitch's "Problem Solving in C++". As far as I am aware this is not written specifically for Microsoft or Unix. So my question is, how does what I am learning in this book (which I am using for my universal knowledge-gaining of c++) differ from what I keep reading about CLI C++?

Is CLI C++ just what I would encounter if I used Visual C++? I'm totally confused.


回答1:


C++/CLI, (Also sometimes C++/CLR) refers to a language which is positioned somewhere in between native C++, and the .NET framework.

It's usually used for applications where you need to bridge some native code (pure C++) and managed code (Like VB, C#, F#, etc).

C++/CLI is a much different beast than regular C++ though. And when people say Visual C++, the meaning can vary depending on context. Sometimes they mean C++ with the common language runtime (CLR) layer enabled, other times they mean just plain C++. It's unfortunate that there's a lot of different terminology out there, and a lot of misnomers, but what can you do?




回答2:


C++ and C++/CLI differ greatly. C++/CLI is the managed .NET-version of C++, made by Microsoft to enable a layer from .NET to native code.




回答3:


c++/cli is the current version of Microsoft's Visual c++ brand of tools. (There was a different design before c++/cli)

c++/cli is really two versions of c++ in one. There is a highly standardized c++ compiler and also a version of c++ that runs on the CLI virtual machine. Obviously standard c++ never runs on a VM so that determined the two in one approach to the language.

When using it you can mix unman aged and managed code together. "Unmanaged" is code compiled just like standard c++. "Managed" is code compiler to the CLI (.Net) virtually machine's bytecode. Microsoft has extensive APIs for both managed and unmanaged code. With the product you can access both APIs.

You can develop standard c++ apps with the language and tool, you just have to be careful not to used the non-standard extensions. I suggest compiling in another compiler once in a while if you are in doubt. The managed side is totally non standard and even the unmanaged side has tons of non standard extensions.

PS I'm no expert but I was curious and read about this last week. I thought your question deserved an answer. Good luck!



来源:https://stackoverflow.com/questions/6399493/what-is-cli-c-exactly-how-does-it-differ-from-normal-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!