简体   繁体   English

什么是纯C++

[英]What is pure C++

What does pure C++ mean?纯C++是什么意思? Please explain the different versions of C++ like Visual C++ and GNU C++.请解释 C++ 的不同版本,如 Visual C++ 和 GNU C++。

How about compilers for these types of C++?这些类型的 C++ 的编译器怎么样?

Pure C++ means C++ as per the ISO standard, with none of the vendor-specific extensions being used.纯 C++ 表示符合 ISO 标准的 C++,没有使用任何供应商特定的扩展。

That means it should be portable across all implementations that support the standard.这意味着它应该可以在支持该标准的所有实现中移植。 Otherwise you may find yourself locked in to a specific vendor, not necessarily a bad thing, but you should understand the implications of that decision.否则,您可能会发现自己被锁定在特定的供应商,这不一定是坏事,但您应该了解该决定的含义。

Pure C++ is the form of C++ which only uses semantics defined by the ISO C++ standard.纯 C++ 是 C++ 的形式,它仅使用 ISO C++ 标准定义的语义。
The code implemented in Pure C++ is fully portable accross all Standard compilant C++ compilers. Pure C++ 中实现的代码可在所有符合标准的 C++ 编译器中完全移植。

Implementations are allowed to provide their own extensions over the features provided by the C++ standard.允许实现对 C++ 标准提供的功能提供自己的扩展。 Each compiler provides so in the form of compiler extensions.每个编译器都以编译器扩展的形式提供。

Thus,因此,

Pure C++ = Features provided by Standard C++纯 C++ = 标准 C++ 提供的功能
Visual C++ = Features provided by Standard C++ + MSVC compiler extensions.视觉 C++ = 标准 C++ + MSVC 编译器扩展提供的功能。
GNU C++ = Features provided by Standard C++ + GNU compiler extensions. GNU C++ = 标准 C++ + GNU 编译器扩展提供的功能。

There is no such thing as "Pure C++".没有“纯 C++”这样的东西。 Either it's C++ or it's not.要么是 C++,要么不是。 There are some companies that have made extensions to C++, that have new keywords like "WinMain", which are not part of the C++ standard.有一些公司对 C++ 进行了扩展,它们有新的关键字,如“WinMain”,这不是 C++ 标准的一部分。 Perhaps that's what you're referring to.也许这就是你所指的。

Stanley Lipman describes the terminology Microsoft invented for their C++/CLI hybrid at http://msdn.microsoft.com/en-us/magazine/cc163852.aspx : Stanley Lipman 在http://msdn.microsoft.com/en-us/magazine/cc163852.aspx描述了 Microsoft 为其 C++/CLI 混合体发明的术语:

C++/CLI represents an integration of the Kansas and Oz of native and managed programming. C++/CLI 代表了 Kansas 和 Oz 本地和托管编程的集成。 In this iteration, that has been done through a kind of separate but equal community of source-level and binary elements, including Mixed mode (source-level mix of native and CTS types, plus a binary mix of native and CIL object files), Pure mode (source-level mix of native and CTS types, all compiled to CIL object files), Native classes (can hold CTS types through a special wrapper class only), and CTS classes (can hold native types only as pointers).在此迭代中,这是通过一种独立但平等的源级和二进制元素社区完成的,包括混合模式(本机和 CTS 类型的源级混合,加上本机和 CIL object 文件的二进制混合),纯模式(原生和 CTS 类型的源代码级混合,全部编译为 CIL object 文件)、原生类(只能通过特殊包装器 class 保存 CTS 类型)和 CTS 类(只能保存原生类型作为指针)。

So, "Pure" C++ in a Microsoft world is a term for a specific blend of proprietary features and ISO Standard C++ features .因此, Microsoft 世界中的“纯”C++ 是专有功能和 ISO 标准 C++ 功能的特定混合的术语

Stanley's description differentiates it from "Native" - which matches what other existing answers to this question describe as "pure". Stanley 的描述将其与“Native”区分开来——后者与该问题的其他现有答案所描述的“纯”相符。 In the general English usage of the word, of course "pure" would be "native" = ISO Standard.在该词的一般英语用法中,“纯”当然是“本地”= ISO 标准。 Ostensibly, Microsoft picked a blatantly misleading term, such that people following tutorials/references on "Pure C++" may be unknowingly locking themselves and their code into use of proprietary Microsoft extensions, and therefore frustrated in any later attempts to port them to other Operating Systems.从表面上看,微软选择了一个公然误导性的术语,这样一来,遵循“纯 C++”教程/参考的人可能会在不知不觉中将自己和他们的代码锁定为使用专有的微软扩展,因此在以后将它们移植到其他操作系统的任何尝试中都会感到沮丧.

terms C++ like Visual C++ and GNU C++. How about compilers for these types of C++.术语 C++,如 Visual C++ 和 GNU C++。这些类型的 C++ 的编译器怎么样。

Visual C++ is Microsoft's brand name for their C++ and C++/CLI compiler. Visual C++ 是 Microsoft 的 C++ 和 C++/CLI 编译器的品牌名称。 GNU is an organisation that produces myriad open-source software products including GCC - the GNU Compiler Collection, which includes a C++ compiler. GNU 是一个生产无数开源软件产品的组织,包括 GCC - GNU 编译器集合,其中包括一个 C++ 编译器。

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

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