简体   繁体   English

ANSI / ISO C ++和C ++ / CLI有什么区别?

[英]What is the difference between ANSI/ISO C++ and C++/CLI?

Created by Microsoft as the foundation of its .NET technology, the Common Language Infrastructure (CLI) is an ECMA standard (ECMA-335) that allows applications to be written in a variety of high-level programming languages and executed in different system environments . 公共语言基础结构(CLI)由Microsoft创建,作为其.NET技术的基础,它是一种ECMA标准(ECMA-335),允许应用程序以各种高级编程语言编写,并在不同的系统环境中执行。 Programming languages that conform to the CLI have access to the same base class library and are capable of being compiled into the same intermediate language (IL) and metadata. 符合CLI的编程语言可以访问相同的基类库,并且能够编译为相同的中间语言(IL)和元数据。 IL is then further compiled into native code particular to a specific architecture. 然后,IL进一步编译为特定于特定体系结构的本机代码。

Because of this intermediate step, applications do not have to be rewritten from scratch. 由于这个中间步骤,不必从头开始重写应用程序。 Their IL only needs to be further compiled into a system's native code. 他们的IL只需要进一步编译成系统的本机代码。

What exactly is meant by the system environments ? 系统环境的确切含义是什么?


Additionally, while studying Ivor Horton's Beginning Visual C++ 2008 , I noticed that he stated that there are fundamentally different kinds of C++ applications can be developed with Visual C++ 2008. These are: 此外,在研究Ivor Horton的Beginning Visual C ++ 2008时 ,我注意到他表示可以使用Visual C ++ 2008开发基本上不同类型的C ++应用程序。这些应用程序包括:

  1. Applications which execute natively on one's computer, which he referred to as native C++ programs . 在一台计算机上本机执行的应用程序,他称之为本机C ++程序 Native C++ programs are written in the version of C++ that is defined by the ISO/ANSI language standard. 本机C ++程序是用ISO / ANSI语言标准定义的C ++版本编写的。

  2. Application can also be written to run under the control of the CLR in an extended version of C++, called C++/CLI. 应用程序也可以编写为在C ++的扩展版本中称为C ++ / CLI的CLR控制下运行。 These programs were referred to as CLR programs , or C++/CLI programs . 这些程序称为CLR程序C ++ / CLI程序

So what is meant by native C++ programs and CLR programs? 那么本机C ++程序和CLR程序是什么意思? What's the difference between them? 他们之间有什么区别? Thanks for any expert's help. 感谢任何专家的帮助。

"System environments" means things like Linux, Windows x86, Windows x64, etc. Notice how they use the term "architecture" interchangeably at the end of the paragraph. “系统环境”意味着像Linux,Windows x86,Windows x64等。请注意它们如何在段落末尾交替使用术语“体系结构”。


A native C++ program is one where you take standard (ANSI/ISO) C++ and you compile it into a .exe. 本机C ++程序是您使用标准(ANSI / ISO)C ++并将其编译为.exe的程序。 Usually you will be compiling this for a specific environment, eg Windows x86, in which case it could not run under Linux and would run under the WoW64 emulation layer on Windows x64. 通常,您将针对特定环境(例如Windows x86)对其进行编译,在这种情况下,它无法在Linux下运行,并且将在Windows x64上的WoW64仿真层下运行。 Notably, this code runs directly on the machine. 值得注意的是,此代码直接在计算机上运行。

C++/CLI is a different programming language than standard C++. C ++ / CLI是一种与标准C ++不同的编程语言。 It, just like C# or VB.NET, runs on top of Microsoft's C ommon L anguage I nterface. 它,就像C#或VB.NET,运行在微软公司的C ommon 大号 anguage 的覆盖整个院落上方。 This means it has access to all those nice things in the paragraph you quoted, like the base class library and compilation to IL which allows it to be run on different architectures. 这意味着它可以访问您引用的段落中的所有这些好东西,比如基类库和IL的编译,它允许它在不同的体系结构上运行。 But, just like C# and VB.NET, it does not run natively on the machine. 但是,就像C#和VB.NET一样,它不能在机器上本机运行。 It requires the installation of the .NET Framework; 它需要安装.NET Framework; part of the .NET Framework's job is translating C++/CLI programs into native programs, which means they have much less direct access to the machine. .NET Framework的一部分工作是将C ++ / CLI程序转换为本机程序,这意味着它们对机器的直接访问要少得多。

I am getting a bit rusty and cannot recall when exactly the word "native" popped up into the common parlance. 我变得有点生疏,无法想起“普通”一词究竟出现在普通用语中。 I believe it was massively used by designers of environments destined to simplify programming running on the top of other ones designed to offer optimal access to system resources with limited focus on the programming style. 我相信它被大量用于简化编程的环境设计人员大量使用,这些环境旨在提供对系统资源的最佳访问,而对编程风格的关注有限。 Which is one may change with the time, as native also may be referred some assembler code invoked from a high level language used to program an embedded system. 哪个可能随时间而变化,因为本机也可能被称为从用于编程嵌入式系统的高级语言调用的一些汇编程序代码。 This is why I avoid using such concepts as operating system as even CLI/CLR despite the common fad may be implemented on Linux (Mono) or on bare silicon with no OS support (.NET Micro). 这就是为什么我避免使用像操作系统这样的概念甚至CLI / CLR,尽管可以在Linux(Mono)或没有OS支持的裸硅上实现常见的时尚(.NET Micro)。

In such a context the standard C++ follows the native approach and is quite tolerant on which hardware or OS (or no OS) it runs as long as it is possible to provide a compiler and the standard library for that. 在这样的上下文中,标准C ++遵循本机方法,并且只要可以为其提供编译器和标准库,就可以完全容忍它运行的硬件或OS(或没有OS)。 The standard C++ code may be easily recompiled for any such platform as far a C++ compiler exists for it. 对于任何此类平台,可以轻松地重新编译标准C ++代码,因为它存在C ++编译器。

To be referred as C++/CLI the C++ dialect implementation needs CLI/CLR support and of course a CLI platform being present but the code may be ported without recompilation using CIL and use a standard, sophisticated library and utilities. 要称为C ++ / CLI,C ++方言实现需要CLI / CLR支持,当然还有CLI平台,但代码可以在不使用CIL重新编译的情况下移植,并使用标准的复杂库和实用程序。 However the initial requirements are higher than in the case of the standard C++ which can play in this case the role of the native environment. 但是,初始要求高于标准C ++的情况,在这种情况下可以起到本机环境的作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM