bebe是什么牌子| 蜜獾为什么什么都不怕| 腹泻吃什么| 5月19日是什么星座| 自投罗网是什么意思| 肠鸣是什么原因| 囊变是什么意思| 四月十五什么星座| 28什么意思| 脑梗吃什么药最好| 梦见死人和棺材预示着什么| 农历今天属什么| 四月四号什么星座| 睾丸痒用什么药膏最好| 海虾不能和什么一起吃| 几乎的意思是什么| 罗汉局是什么意思| 红蜘蛛用什么药| 摩卡棕是什么颜色| 尿频繁吃什么药最见效| 黑色的猫是什么品种| 梦见大领导有什么预兆| casio手表是什么牌子| 检查hpv需要注意什么提前注意什么| 血红素是什么| 筋头巴脑是什么东西| 注意身体是什么意思| 冰粉籽是什么植物| 彩排是什么意思| 皮赘是什么原因引起的| 精力是什么意思| 昏昏欲睡是什么意思| 幽门螺杆菌用什么药| bella是什么意思| 怀孕1个月有什么症状| 肝癌有什么症状| 为什么会做噩梦| 皮肤黑的人穿什么颜色的衣服好看| 尿频尿急尿不尽吃什么药最快见效| 肾检查挂什么科| 海带有什么营养| 奕字属于五行属什么| 眼皮肿是什么原因| 鸟屎掉头上有什么预兆| 有编制是什么意思| 血糖低吃什么补得最快| 7.6什么星座| 壁虎代表什么生肖| 检查贫血做什么检查| 打胎后要注意什么| 披靡是什么意思| 囧途什么意思| rj什么意思| 腋下疣是什么原因造成的| 鳞状上皮增生是什么病| 淡盐水有什么作用和功效| 男羊配什么属相最好| 真如是什么意思| 28岁属相是什么生肖| 新生儿吃什么钙好| 子宫癌筛查做什么检查| 十二月九号是什么星座| 月字旁的字和什么有关| 甲醛是什么东西| 天梭属于什么档次| 裹腹是什么意思| 什么样的人不能坐飞机| 计数是什么意思| 农历六月十四是什么日子| 肌酐高是什么问题| 阳气不足吃什么中成药| 点了斑不能吃什么| 肋间神经痛挂什么科| 脂肪肝适合吃什么食物| 洋葱有什么功效| 血虚吃什么食物可以补| 2025年什么年| 梦见抓了好多鱼是什么意思| 花椒木有什么作用与功效| 井泉水命什么意思| 驾驶证照片是什么底色| 溜溜是什么意思| 牙髓炎是什么原因引起的| 嗜睡乏力没精神容易疲劳是什么原因| 脱脂牛奶适合什么人喝| 达泊西汀有什么副作用| 灰指甲是什么样的图片| 小三阳吃什么药能转阴| 低烧挂什么科| 舅舅和外甥女是什么关系| 龙傲天是什么意思| 7.11是什么日子| 什么的拳头| lof是什么意思| 指甲月牙白代表什么| 6.5号是什么星座| 一到晚上就饿什么原因| 吃什么治疗便秘| 血糖高适合吃什么食物| 朗姆是什么| 赖床什么意思| 火麻是什么植物| 子宫内膜3mm意味着什么| 血小板低看什么科| 琥珀是什么颜色| 肌酐是什么意思| 水险痣是什么意思| 身份证照片穿什么颜色衣服| 反复发烧挂什么科| 四海是什么意思| 流汗多是什么原因| 一龙一什么填十二生肖| style是什么意思| 水瓜有什么作用和功效| 心脏b超能查出什么| 梦见西红柿什么意思| 木加一笔有什么字| 狗狗湿疹用什么药膏最有效| 梦见下大雨是什么征兆| 杀青是什么意思| 佛灯火命是什么意思| 来姨妈不能吃什么| 乌鱼子是什么意思| 知更鸟是什么鸟| 拉肚子什么原因造成的| 小便次数多吃什么药| 旗袍穿什么鞋子好看图| 宫腔镜是检查什么的| 团购是什么意思| 头出汗多至头发湿透是什么原因| 性激素六项检查是什么| 肝肾衰竭有什么症状| 斩衰是什么意思| 芡实不能和什么一起吃| 口臭吃什么药| 反复发烧是什么原因| 男人嘴唇薄代表什么| 神经系统由什么组成| 膀胱充盈欠佳什么意思| 高铁上不能带什么| 风寒感冒咳嗽吃什么药| 胃疼检查什么项目| 额头长痘痘是什么原因| 霉菌性阴道炎用什么药好得快| 3月25日是什么星座| 玛尼是什么意思| 酱油的原料是什么| 演宋江的演员叫什么| 首战告捷什么意思| 鱼龙是什么| 背部疼痛是什么原因引起的| cinderella是什么意思| 减肥为什么不让吃茄子| 下午2点半是什么时辰| 甲状旁腺分泌什么激素| 每天泡脚对身体有什么好处| 耳朵轮廓痒是什么原因| yy是什么意思| 做月子要注意什么| 胸痛应该挂什么科| as是什么| 补办身份证要带什么| 孕妇口腔溃疡能用什么药| 阅读有什么好处| 杀鸡取卵是什么生肖| 人生得意须尽欢什么意思| 静脉曲张吃什么药| 前列腺增生吃什么药最好| 什么的蔷薇| 屈膝是什么意思| 耳鸣是什么病引起的| 为什么要拔智齿| 失聪是什么原因造成的| 为什么不呢| 犀利哥什么意思| 吃炒黑豆有什么好处和坏处| 嘴干嘴苦是什么原因| 渺渺是什么意思| 慢性肠炎是什么症状| 什么是赌博| 孩子经常流鼻血是什么原因| 庄周梦蝶是什么意思| 落花流水什么意思| 青年补钙吃什么好| 一饿就胃疼是什么原因| 颈椎病睡什么枕头最好| 受之无愧的意思是什么| 为什么有的| 骨质增生吃什么药最好| 什么叫磁场| 肾亏吃什么好| 构筑物是什么意思| 日和立念什么| 什么是童话故事| 咳嗽消炎药吃什么好| 鸾俦是什么意思| 眼睛有血丝是什么原因| 什么人需要做心脏造影| 精分是什么| 尿不出尿是什么原因| vt是什么| 小腿发痒是什么原因| 硬着头皮是什么意思| 吃什么瘦肚子最快| 火龙果是什么颜色| c1e驾照能开什么车| 糖皮质激素是什么药| 秋天喝什么粥好| 吃什么对神经恢复快速| 老干部是什么意思| 世袭罔替是什么意思| 鱼非念什么| 蜂王浆什么时间吃最好| 什么叫动脉硬化| 漏斗胸为什么长不胖| esd是什么| 南北朝后面是什么朝代| 岂是什么意思| 1109是什么星座| 杏和什么不能一起吃| 嗨体水光针有什么功效| 牙齿为什么会痛| 西柚不能和什么一起吃| 胸骨疼挂什么科| 减肥晚上吃什么合适| 山楂和什么泡水喝减肥效果最好| 古今内衣是什么档次| 鼻子发干是什么原因造成的| 什么的跳舞| 毓婷是什么药| 验血能查出什么病| 脸肿脚肿是什么原因引起的| 1988年属什么| 脸上爱出油是什么原因| 正师级相当于地方什么级别| 入驻是什么意思| 肩膀上的肌肉叫什么| 牛蒡茶有什么功效| 爱理不理是什么意思| 人中短代表什么| 不成功便成仁的仁是什么意思| ky什么意思| 58年属什么生肖| 头臀径是指什么| pof是什么意思| 纷乐是什么药| 帕金森挂什么科| 隽字五行属什么| 女性膀胱炎吃什么药| 皮脂腺囊肿吃什么消炎药| 斯人是什么意思| 出尔反尔是什么意思| 心脏早搏吃什么药最好| 为什么会得白癜风| 调月经吃什么药好| 什么叫转基因| 壳心念什么| 包饺子用什么面粉| 法院起诉离婚需要什么材料| 爸爸的哥哥叫什么| 海带为什么要打结| 田螺吃什么食物| 脸色发黑是什么病的前兆| 射手座属于什么星象| 百度Jump to content

傲斗凌云1.2.2破解版【45个定制英雄+平台福利】

From Wikipedia, the free encyclopedia
百度 但她觉得Africa很可爱,而且总是笑。

C++
Logo endorsed by the C++ standards committee
ParadigmsMulti-paradigm: procedural, imperative, functional, object-oriented, generic, modular
FamilyC
Designed byBjarne Stroustrup
DeveloperISO/IEC JTC 1 (Joint Technical Committee 1) / SC 22 (Subcommittee 22) / WG 21 (Working Group 21)
First appeared1985; 40 years ago (1985)
Stable release
C++23 (ISO/IEC 14882:2024) / 19 October 2024; 9 months ago (2025-08-06)
Preview release
C++26 / 16 October 2024; 9 months ago (2025-08-06)
Typing disciplineStatic, strong, nominative, partially inferred
OSCross-platform
Filename extensions.C, .cc, .cpp, .cxx, .c++, .h, .H, .hh, .hpp, .hxx, .h++ .cppm, .ixx[1]
Websiteisocpp.org
Major implementations
GCC, LLVM Clang, Microsoft Visual C++, Embarcadero C++Builder, Intel C++ Compiler, IBM XL C++, EDG
Influenced by
Ada, ALGOL 68,[2] BCPL,[3] C, CLU,[2] F#,[4][note 1] ML, Mesa,[2] Modula-2,[2] Simula, Smalltalk[2]
Influenced
Ada 95, C#,[5] C99, Carbon, Chapel,[6] Clojure,[7] D, Java,[8] JS++,[9] Lua,[10] Nim,[11] Objective-C++, Perl, PHP, Python,[12] Rust,[13] Seed7

C++ (/?si? pl?s pl?s/, pronounced "C plus plus" and sometimes abbreviated as CPP or CXX) is a high-level, general-purpose programming language created by Danish computer scientist Bjarne Stroustrup. First released in 1985 as an extension of the C programming language, adding object-oriented (OOP) features, it has since expanded significantly over time adding more OOP and other features; as of 1997/C++98 standardization, C++ has added functional features, in addition to facilities for low-level memory manipulation for systems like microcomputers or to make operating systems like Linux or Windows, and even later came features like generic programming (through the use of templates). C++ is usually implemented as a compiled language, and many vendors provide C++ compilers, including the Free Software Foundation, LLVM, Microsoft, Intel, Embarcadero, Oracle, and IBM.[14]

C++ was designed with systems programming and embedded, resource-constrained software and large systems in mind, with performance, efficiency, and flexibility of use as its design highlights.[15] C++ has also been found useful in many other contexts, with key strengths being software infrastructure and resource-constrained applications,[15] including desktop applications, video games, servers (e.g., e-commerce, web search, or databases), and performance-critical applications (e.g., telephone switches or space probes).[16]

C++ is standardized by the International Organization for Standardization (ISO), with the latest standard version ratified and published by ISO in October 2024 as ISO/IEC 14882:2024 (informally known as C++23).[17] The C++ programming language was initially standardized in 1998 as ISO/IEC 14882:1998, which was then amended by the C++03, C++11, C++14, C++17, and C++20 standards. The current C++23 standard supersedes these with new features and an enlarged standard library. Before the initial standardization in 1998, C++ was developed by Stroustrup at Bell Labs since 1979 as an extension of the C language; he wanted an efficient and flexible language similar to C that also provided high-level features for program organization.[18] Since 2012, C++ has been on a three-year release schedule[19] with C++26 as the next planned standard.[20]

Despite its widespread adoption, some notable programmers have criticized the C++ language, including Linus Torvalds,[21] Richard Stallman,[22] Joshua Bloch, Ken Thompson,[23][24][25] and Donald Knuth.[26][27]

History

[edit]
Bjarne Stroustrup, the creator of C++, in his AT&T New Jersey office, c.?2000

In 1979, Bjarne Stroustrup, a Danish computer scientist, began work on "C with Classes", the predecessor to C++.[28] The motivation for creating a new language originated from Stroustrup's experience in programming for his PhD thesis. Stroustrup found that Simula had features that were very helpful for large software development, but the language was too slow for practical use, while BCPL was fast but too low-level to be suitable for large software development. When Stroustrup started working in AT&T Bell Labs, he had the problem of analyzing the UNIX kernel with respect to distributed computing. Remembering his PhD experience, Stroustrup set out to enhance the C language with Simula-like features.[29] C was chosen because it was general-purpose, fast, portable, and widely used. In addition to C and Simula's influences, other languages influenced this new language, including ALGOL 68, Ada, CLU, and ML.[citation needed]

Initially, Stroustrup's "C with Classes" added features to the C compiler, Cpre, including classes, derived classes, strong typing, inlining, and default arguments.[30]

A quiz on C++11 features being given in Paris in 2015

In 1982, Stroustrup started to develop a successor to C with Classes, which he named "C++" (++ being the increment operator in C) after going through several other names. New features were added, including virtual functions, function and operator overloading, references, constants, type-safe free-store memory allocation (new/delete), improved type checking, and BCPL-style single-line comments with two forward slashes (//). Furthermore, Stroustrup developed a new, standalone compiler for C++, Cfront.

In 1984, Stroustrup implemented the first stream input/output library. The idea of providing an output operator rather than a named output function was suggested by Doug McIlroy[2] (who had previously suggested Unix pipes).

In 1985, the first edition of The C++ Programming Language was released, which became the definitive reference for the language, as there was not yet an official standard.[31] The first commercial implementation of C++ was released in October of the same year.[28]

In 1989, C++ 2.0 was released, followed by the updated second edition of The C++ Programming Language in 1991.[32] New features in 2.0 included multiple inheritance, abstract classes, static member functions, const member functions, and protected members. In 1990, The Annotated C++ Reference Manual was published. This work became the basis for the future standard. Later feature additions included templates, exceptions, namespaces, new casts, and a Boolean type.

In 1998, C++98 was released, standardizing the language, and a minor update (C++03) was released in 2003.

After C++98, C++ evolved relatively slowly until, in 2011, the C++11 standard was released, adding numerous new features, enlarging the standard library further, and providing more facilities to C++ programmers. After a minor C++14 update released in December 2014, various new additions were introduced in C++17.[33] After becoming finalized in February 2020,[34] a draft of the C++20 standard was approved on 4 September 2020, and officially published on 15 December 2020.[35][36]

On January 3, 2018, Stroustrup was announced as the 2018 winner of the Charles Stark Draper Prize for Engineering, "for conceptualizing and developing the C++ programming language".[37]

In December 2022, C++ ranked third on the TIOBE index, surpassing Java for the first time in the history of the index. As of November 2024, the language ranks second after Python, with Java being in third.[38]

In March 2025, Stroustrup issued a call for the language community to defend it. Since the language allows manual memory management, bugs that represent security risks such as buffer overflow may be introduced in programs when inadvertently misused by the programmer.[39]

Etymology

[edit]

According to Stroustrup, "the name signifies the evolutionary nature of the changes from C."[40] This name is credited to Rick Mascitti (mid-1983)[30] and was first used in December 1983. When Mascitti was questioned informally in 1992 about the naming, he indicated that it was given in a tongue-in-cheek spirit. The name comes from C's ++ operator (which increments the value of a variable) and a common naming convention of using "+" to indicate an enhanced computer program.

During C++'s development period, the language had been referred to as "new C" and "C with Classes"[30][41] before acquiring its final name.

Philosophy

[edit]

Throughout C++'s life, its development and evolution has been guided by a set of principles:[29]

  • It must be driven by actual problems and its features should be immediately useful in real world programs.
  • Every feature should be implementable (with a reasonably obvious way to do so).
  • Programmers should be free to pick their own programming style, and that style should be fully supported by C++.
  • Allowing a useful feature is more important than preventing every possible misuse of C++.
  • It should provide facilities for organizing programs into separate, well-defined parts, and provide facilities for combining separately developed parts.
  • No implicit violations of the type system (but allow explicit violations; that is, those explicitly requested by the programmer).
  • User-created types need to have the same support and performance as built-in types.
  • Unused features should not negatively impact created executables (e.g. in lower performance).
  • There should be no language beneath C++ (except assembly language).
  • C++ should work alongside other existing programming languages, rather than fostering its own separate and incompatible programming environment.
  • If the programmer's intent is unknown, allow the programmer to specify it by providing manual control.

Standardization

[edit]
C++ standards
Year ISO/IEC Standard Informal name
1998 14882:1998[42] C++98
2003 14882:2003[43] C++03
2011 14882:2011[44] C++11, C++0x
2014 14882:2014[45] C++14, C++1y
2017 14882:2017[46] C++17, C++1z
2020 14882:2020[47] C++20, C++2a
2024 14882:2024[17] C++23, C++2b
TBA C++26, C++2c

C++ is standardized by an ISO working group known as JTC1/SC22/WG21. So far, it has published seven revisions of the C++ standard and is currently working on the next revision, C++26.

Scene during the C++ standards committee meeting in Stockholm in 1996

In 1998, the ISO working group standardized C++ for the first time as ISO/IEC 14882:1998, which is informally known as C++98. In 2003, it published a new version of the C++ standard called ISO/IEC 14882:2003, which fixed problems identified in C++98.

The next major revision of the standard was informally referred to as "C++0x", but it was not released until 2011.[48] C++11 (14882:2011) included many additions to both the core language and the standard library.[44]

In 2014, C++14 (also known as C++1y) was released as a small extension to C++11, featuring mainly bug fixes and small improvements.[49] The Draft International Standard ballot procedures completed in mid-August 2014.[50]

After C++14, a major revision C++17, informally known as C++1z, was completed by the ISO C++ committee in mid July 2017 and was approved and published in December 2017.[51]

As part of the standardization process, ISO also publishes technical reports and specifications:

  • ISO/IEC TR 18015:2006[52] on the use of C++ in embedded systems and on performance implications of C++ language and library features,
  • ISO/IEC TR 19768:2007[53] (also known as the C++ Technical Report 1) on library extensions mostly integrated into C++11,
  • ISO/IEC TR 29124:2010[54] on special mathematical functions, integrated into C++17,
  • ISO/IEC TR 24733:2011[55] on decimal floating-point arithmetic,
  • ISO/IEC TS 18822:2015[56] on the standard filesystem library, integrated into C++17,
  • ISO/IEC TS 19570:2015[57] on parallel versions of the standard library algorithms, integrated into C++17,
  • ISO/IEC TS 19841:2015[58] on software transactional memory,
  • ISO/IEC TS 19568:2015[59] on a new set of library extensions, some of which are already integrated into C++17,
  • ISO/IEC TS 19217:2015[60] on the C++ concepts, integrated into C++20,
  • ISO/IEC TS 19571:2016[61] on the library extensions for concurrency, some of which are already integrated into C++20,
  • ISO/IEC TS 19568:2017[62] on a new set of general-purpose library extensions,
  • ISO/IEC TS 21425:2017[63] on the library extensions for ranges, integrated into C++20,
  • ISO/IEC TS 22277:2017[64] on coroutines, integrated into C++20,
  • ISO/IEC TS 19216:2018[65] on the networking library,
  • ISO/IEC TS 21544:2018[66] on modules, integrated into C++20,
  • ISO/IEC TS 19570:2018[67] on a new set of library extensions for parallelism
  • ISO/IEC TS 23619:2021[68] on new extensions for reflective programming (reflection),
  • ISO/IEC TS 9922:2024[69] on new set of concurrency extensions, and
  • ISO/IEC TS 19568:2024[70] on another new set of library extensions.

More technical specifications are in development and pending approval.

Language

[edit]

The C++ language has two main components: a direct mapping of hardware features provided primarily by the C subset, and zero-overhead abstractions based on those mappings. Stroustrup describes C++ as "a light-weight abstraction programming language [designed] for building and using efficient and elegant abstractions";[15] and "offering both hardware access and abstraction is the basis of C++. Doing it efficiently is what distinguishes it from other languages."[71]

C++ inherits most of C's syntax. A hello world program that conforms to the C standard is also a valid C++ hello world program. The following is Bjarne Stroustrup's version of the Hello world program that uses the C++ Standard Library stream facility to write a message to standard output:[72][73][note 2]

#include <iostream>

int main()
{
    std::cout << "Hello, world!\n";
}

Standard library

[edit]
The draft "Working Paper" standard that became approved as C++98; half of its size was devoted to the C++ Standard Library.

The C++ standard consists of two parts: the core language and the standard library. C++ programmers expect the latter on every major implementation of C++; it includes aggregate types (vectors, lists, maps, sets, queues, stacks, arrays, tuples), algorithms (find, for_each, binary_search, random_shuffle, etc.), input/output facilities (iostream, for reading from and writing to the console and files), filesystem library, localisation support, smart pointers for automatic memory management, regular expression support, multi-threading library, atomics support (allowing a variable to be read or written to by at most one thread at a time without any external synchronisation), time utilities (measurement, getting current time, etc.), a system for converting error reporting that does not use C++ exceptions into C++ exceptions, a random number generator, and a slightly modified version of the C standard library (to make it comply with the C++ type system).

A large part of the C++ library is based on the Standard Template Library (STL). Useful tools provided by the STL include containers as the collections of objects (such as vectors and lists), iterators that provide array-like access to containers, and algorithms that perform operations such as searching and sorting.

Furthermore, (multi)maps (associative arrays) and (multi)sets are provided, all of which export compatible interfaces. Therefore, using templates it is possible to write generic algorithms that work with any container or on any sequence defined by iterators.

As in C, the features of the library may be accessed by using the #include directive to include a standard header. The C++ Standard Library provides 105 standard headers, of which 27 are deprecated. With the introduction of modules in C++20, these headers may be accessed with import, and in C++23, the entire standard library can now be directly imported as module itself, with import std;. Currently, the C++ standard library provides two modules, std and std.compat (a compatibility module for std which exports C standard library facilities into the global namespace).

The standard incorporates the STL that was originally designed by Alexander Stepanov, who experimented with generic algorithms and containers for many years. When he started with C++, he finally found a language where it was possible to create generic algorithms (e.g., STL sort) that perform even better than, for example, the C standard library qsort, thanks to C++ features like using inlining and compile-time binding instead of function pointers. The standard does not refer to it as "STL", as it is merely a part of the standard library, but the term is still widely used to distinguish it from the rest of the standard library (input/output streams, internationalization, diagnostics, the C library subset, etc.).[74]

Most C++ compilers, and all major ones, provide a standards-conforming implementation of the C++ standard library.

C++ Core Guidelines

[edit]

The C++ Core Guidelines[75] are an initiative led by Bjarne Stroustrup, the inventor of C++, and Herb Sutter, the convener and chair of the C++ ISO Working Group, to help programmers write 'Modern C++' by using best practices for the language standards C++11 and newer, and to help developers of compilers and static checking tools to create rules for catching bad programming practices.

The main aim is to efficiently and consistently write type and resource safe C++.

The Core Guidelines were announced[76] in the opening keynote at CPPCon 2015.

The Guidelines are accompanied by the Guideline Support Library (GSL),[77] a header only library of types and functions to implement the Core Guidelines and static checker tools for enforcing Guideline rules.[78]

Compatibility

[edit]

To give compiler vendors greater freedom, the C++ standards committee decided not to dictate the implementation of name mangling, exception handling, and other implementation-specific features. The downside of this decision is that object code produced by different compilers is expected to be incompatible. There are, however, attempts to standardize compilers for particular machines or operating systems. For example, the Itanium C++ ABI is processor-independent (despite its name) and is implemented by GCC and Clang.[79]

With C

[edit]

C++ is often considered to be a superset of C but this is not strictly true.[80] Most C code can easily be made to compile correctly in C++ but there are a few differences that cause some valid C code to be invalid or behave differently in C++. For example, C allows implicit conversion from void* to other pointer types but C++ does not (for type safety reasons). Also, C++ defines many new keywords, such as new and class, which may be used as identifiers (for example, variable names) in a C program.

Some incompatibilities have been removed by the 1999 revision of the C standard (C99), which now supports C++ features such as line comments (//) and declarations mixed with code. On the other hand, C99 introduced a number of new features that C++ did not support that were incompatible or redundant in C++, such as variable-length arrays, native complex-number types (however, the std::complex class in the C++ standard library provides similar functionality, although not code-compatible), designated initializers, compound literals, and the restrict keyword.[81] Some of the C99-introduced features were included in the subsequent version of the C++ standard, C++11 (out of those which were not redundant).[82][83][84] However, the C++11 standard introduces new incompatibilities, such as disallowing assignment of a string literal to a character pointer, which remains valid C.

To intermix C and C++ code, any function declaration or definition that is to be called from/used both in C and C++ must be declared with C linkage by placing it within an extern "C" {/*...*/} block. Such a function may not rely on features depending on name mangling (i.e., function overloading).

Inline assembly

[edit]

Programs developed in C or C++ often utilize inline assembly to take advantage of its low-level functionalities, greater speed, and enhanced control compared to high-level programming languages[85][86] when optimizing for performance is essential. C++ provides support for embedding assembly language using asm declarations,[87] but the compatibility of inline assembly varies significantly between compilers and architectures. Unlike high-level language features such as Python or Java, assembly code is highly dependent on the underlying processor and compiler implementation.

Variations across compilers

[edit]

Different C++ compilers implement inline assembly in distinct ways.

  • GCC (GNU Compiler Collection) and Clang:[88] Use the GCC extended inline assembly syntax. Using __asm__ keyword instead of asm when writing code that can be compiled with -ansi and -std options, which allows specifying input/output operands and clobbered registers. This approach is widely adopted, including by Intel[89] and IBM[90] compilers.
  • MSVC (Microsoft Visual C++): The inline assembler is built into the compiler. Previously supported inline assembly via the __asm keyword, but this support has been removed in 64-bit mode, requiring separate .asm modules instead.[91]
  • TI ARM Clang and Embedded Compilers:[92] Some embedded system compilers, like Texas Instruments' TI Arm Clang, allow inline assembly but impose stricter rules to avoid conflicts with register conventions and calling conventions.

Interoperability between C++ and Assembly

[edit]

C++ provides two primary methods of integrating ASM code.

1. Standalone assembly files – Assembly code is written separately and linked with C++ code.[93]

2. Inline assembly – Assembly code is embedded within C++ code using compiler-specific extensions.

Example Code for ASM Compatibility
  • When calling an assembly function from C++, use extern "C" to prevent C++ name mangling.
//main.cpp
import std;

extern "C" int add_asm(int, int);  // Declare the assembly function

int main() {
    int result = add_asm(5, 7);
    std::println("Result from ASM: {}", result);
    return 0;
}
#asm code using RISC-V architecture
.section .text
.global add_asm

add_asm:
    add a0, a0, a1  # Add first argument (a0) and second argument (a1), store in a0
    ret             # Return (a0 holds return value)
  • Global variables in assembly must be declared as extern in C++ and marked .global in assembly.
// main.cpp
import std;

extern "C" int global_var;  // Declare global variable from assembly

int main() {
    std::println("Global variable from ASM: {}", global_var);
    return 0;
}
#asm using RISC-V architecture
.section .data
.global global_var
.align 4
global_var:
    .word 42   # Define integer value
  • Inline assembly allows embedding ASM directly in C++ using the asm keyword.
//main.cpp (using GCC/CLANG compiler)
import std;

int main() {
    int x = 10, y = 20, sum;

    asm volatile (
        "add %0, %1, %2"
        : "=r" (sum)   // Output operand (stored in a register)
        : "r" (x), "r" (y) // Input operands (stored in registers)
    );

    std::println("Sum using inline ASM: {}", sum);
    return 0;
}

See also

[edit]

Footnotes

[edit]
  1. ^ For the idea of the C++20 stackless coroutines.
  2. ^ This code is copied directly from Bjarne Stroustrup's errata page (p. 633). He addresses the use of '\n' rather than std::endl. Also see Can I write "void main()"? Archived 2 July 2020 at the Wayback Machine for an explanation of the implicit return 0; in the main function. This implicit return is not available in other functions.

References

[edit]
  1. ^ "Overview of modules in C++". Microsoft. 24 April 2023.
  2. ^ a b c d e f Stroustrup, Bjarne (1996). "A history of C++: 1979-1991". History of programming languages---II. ACM. pp. 699–769. doi:10.1145/234286.1057836.
  3. ^ Stroustrup, Bjarne (16 December 2021). "C++20: Reaching for the Aims of C++ - Bjarne Stroustrup - CppCon 2021". CppCon. Archived from the original on 30 December 2021. Retrieved 30 December 2021.
  4. ^ Stroustrup, Bjarne (12 June 2020). "Thriving in a crowded and changing world: C++ 2006–2020". Proceedings of the ACM on Programming Languages. 4 (HOPL). Association for Computing Machinery (ACM): 1–168. doi:10.1145/3386320. ISSN 2475-1421. S2CID 219603741.
  5. ^ Naugler, David (May 2007). "C# 2.0 for C++ and Java programmer: conference workshop". Journal of Computing Sciences in Colleges. 22 (5). Although C# has been strongly influenced by Java it has also been strongly influenced by C++ and is best viewed as a descendant of both C++ and Java.
  6. ^ "Chapel spec (Acknowledgements)" (PDF). Cray Inc. 1 October 2015. Archived (PDF) from the original on 24 June 2018. Retrieved 14 January 2016.
  7. ^ Fogus, Michael. "Rich Hickey Q&A". Code Quarterly. Archived from the original on 11 January 2017. Retrieved 11 January 2017.
  8. ^ Harry. H. Chaudhary (28 July 2014). "Cracking The Java Programming Interview :: 2000+ Java Interview Que/Ans". Archived from the original on 27 May 2021. Retrieved 29 May 2016.
  9. ^ Roger Poon (1 May 2017). "Scaling JS++: Abstraction, Performance, and Readability". Archived from the original on 11 May 2020. Retrieved 21 April 2020.
  10. ^ "The evolution of an extension language: a history of Lua". www.lua.org. Retrieved 4 January 2023.
  11. ^ "FAQ Nim Programming Language". Archived from the original on 11 July 2017. Retrieved 21 April 2020.
  12. ^ "9. Classes — Python 3.6.4 documentation". docs.python.org. Archived from the original on 23 October 2012. Retrieved 9 January 2018.
  13. ^ "Influences - The Rust Reference". doc.rust-lang.org. Retrieved 4 January 2023.
  14. ^ Stroustrup, Bjarne (1997). "1". The C++ Programming Language (Third ed.). Addison-Wesley. ISBN 0-201-88954-4. OCLC 59193992.
  15. ^ a b c Stroustrup, B. (6 May 2014). "Lecture:The essence of C++. University of Edinburgh". YouTube. Archived from the original on 28 April 2015. Retrieved 12 June 2015.
  16. ^ Stroustrup, Bjarne (17 February 2014). "C++ Applications". stroustrup.com. Archived from the original on 4 April 2021. Retrieved 5 May 2014.
  17. ^ a b "ISO/IEC 14882:2024". International Organization for Standardization. Retrieved 21 October 2020.
  18. ^ "Bjarne Stroustrup's Homepage". www.stroustrup.com. Archived from the original on 14 May 2019. Retrieved 15 May 2013.
  19. ^ "C++ IS schedule" (PDF). Archived (PDF) from the original on 10 August 2020. Retrieved 9 August 2020.
  20. ^ "C++; Where it's heading". Archived from the original on 3 December 2018. Retrieved 3 December 2018.
  21. ^ "Re: [RFC] Convert builin-mailinfo.c to use The Better String Library" (Mailing list). 6 September 2007. Archived from the original on 8 March 2021. Retrieved 31 March 2015.
  22. ^ "Re: Efforts to attract more users?" (Mailing list). 12 July 2010. Archived from the original on 21 March 2015. Retrieved 31 March 2015.
  23. ^ Andrew Binstock (18 May 2011). "Dr. Dobb's: Interview with Ken Thompson". Dr. Dobb's. Archived from the original on 13 March 2014. Retrieved 7 February 2014.
  24. ^ Peter Seibel (16 September 2009). Coders at Work: Reflections on the Craft of Programming. Apress. pp. 475–476. ISBN 978-1-4302-1948-4. Archived from the original on 1 December 2019. Retrieved 9 November 2017.
  25. ^ "C++ in Coders at Work". 16 October 2009. Archived from the original on 10 November 2017. Retrieved 9 November 2017.
  26. ^ "An Interview with Donald Knuth". Dr. Dobb's. Archived from the original on 8 March 2021. Retrieved 18 July 2021.
  27. ^ "(La)TeX Navigator". Archived from the original on 20 November 2017. Retrieved 10 November 2017.
  28. ^ a b Stroustrup, Bjarne (7 March 2010). "Bjarne Stroustrup's FAQ: When was C++ invented?". stroustrup.com. Archived from the original on 6 February 2016. Retrieved 16 September 2010.
  29. ^ a b Stroustrup, Bjarne. "Evolving a language in and for the real world: C++ 1991-2006" (PDF). Archived (PDF) from the original on 20 November 2007. Retrieved 14 August 2013.
  30. ^ a b c Stroustrup, Bjarne. "A History of C ++ : 1979? 1991" (PDF). Archived (PDF) from the original on 2 February 2019. Retrieved 18 July 2013.
  31. ^ Stroustrup, Bjarne. "The C++ Programming Language" (First ed.). Archived from the original on 9 August 2012. Retrieved 16 September 2010.
  32. ^ Stroustrup, Bjarne. "The C++ Programming Language" (Second ed.). Archived from the original on 9 August 2012. Retrieved 16 September 2010.
  33. ^ Sutter, Herb (30 June 2016). "Trip report: Summer ISO C++ standards meeting (Oulu)". herbsutter.com. Archived from the original on 8 October 2016. the next standard after C++17 will be C++20
  34. ^ Dusíková, Hana (6 November 2019). "N4817: 2020 Prague Meeting Invitation and Information" (PDF). Archived (PDF) from the original on 29 December 2019. Retrieved 13 February 2020.
  35. ^ "Current Status". isocpp.org. Archived from the original on 8 September 2020. Retrieved 7 September 2020.
  36. ^ "C++20 Approved -- Herb Sutter". isocpp.org. Archived from the original on 11 September 2020. Retrieved 8 September 2020.
  37. ^ "Computer Science Pioneer Bjarne Stroustrup to Receive the 2018 Charles Stark Draper Prize for Engineering" (Press release). National Academy of Engineering. 3 January 2018. Archived from the original on 3 January 2018. Retrieved 14 December 2021.
  38. ^ TIOBE (November 2024). "TIOBE Index for November 2024". TIOBE.com. TIOBE Company. Archived from the original on 18 November 2024. Retrieved 18 November 2024.
  39. ^ Claburn, Thomas (2 March 2025). "C++ creator calls for help to defend programming language from 'serious attacks'". The Register. Retrieved 5 March 2025.
  40. ^ "Bjarne Stroustrup's FAQ – Where did the name "C++" come from?". Archived from the original on 6 February 2016. Retrieved 16 January 2008.
  41. ^ "C For C++ Programmers". Northeastern University. Archived from the original on 17 November 2010. Retrieved 7 September 2015.
  42. ^ "ISO/IEC 14882:1998". International Organization for Standardization. Archived from the original on 15 January 2017. Retrieved 23 November 2018.
  43. ^ "ISO/IEC 14882:2003". International Organization for Standardization. Archived from the original on 13 August 2021. Retrieved 23 November 2018.
  44. ^ a b "ISO/IEC 14882:2011". International Organization for Standardization. Archived from the original on 27 May 2016. Retrieved 23 November 2018.
  45. ^ "ISO/IEC 14882:2014". International Organization for Standardization. Archived from the original on 29 April 2016. Retrieved 23 November 2018.
  46. ^ "ISO/IEC 14882:2017". International Organization for Standardization. Archived from the original on 29 January 2013. Retrieved 2 December 2017.
  47. ^ "ISO/IEC 14882:2020". International Organization for Standardization. Archived from the original on 16 December 2020. Retrieved 16 December 2020.
  48. ^ "We have an international standard: C++0x is unanimously approved". Sutter's Mill. 12 August 2011. Archived from the original on 28 June 2018. Retrieved 23 November 2018.
  49. ^ "The Future of C++". Archived from the original on 23 October 2018. Retrieved 23 November 2018 – via channel9.msdn.com.
  50. ^ "We have C++14! : Standard C++". isocpp.org. Archived from the original on 19 August 2014. Retrieved 19 August 2014.
  51. ^ Sutter, Herb (15 July 2017). "Trip report: Summer ISO C++ standards meeting (Toronto)". Archived from the original on 6 August 2017. Retrieved 4 August 2017.
  52. ^ "ISO/IEC TR 18015:2006". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  53. ^ "ISO/IEC TR 19768:2007". International Organization for Standardization. Archived from the original on 4 March 2016. Retrieved 15 February 2019.
  54. ^ "ISO/IEC TR 29124:2010". International Organization for Standardization. Archived from the original on 12 January 2019. Retrieved 15 February 2019.
  55. ^ "ISO/IEC TR 24733:2011". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  56. ^ "ISO/IEC TS 18822:2015". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  57. ^ "ISO/IEC TS 19570:2015". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  58. ^ "ISO/IEC TS 19841:2015". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  59. ^ "ISO/IEC TS 19568:2015". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  60. ^ "ISO/IEC TS 19217:2015". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  61. ^ "ISO/IEC TS 19571:2016". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  62. ^ "ISO/IEC TS 19568:2017". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  63. ^ "ISO/IEC TS 21425:2017". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  64. ^ "ISO/IEC TS 22277:2017". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  65. ^ "ISO/IEC TS 19216:2018". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  66. ^ "ISO/IEC TS 21544:2018". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  67. ^ "ISO/IEC TS 19570:2018". International Organization for Standardization. Archived from the original on 15 January 2019. Retrieved 15 February 2019.
  68. ^ "ISO/IEC TS 23619:2021". International Organization for Standardization. Archived from the original on 15 December 2018. Retrieved 11 October 2021.
  69. ^ "ISO/IEC TS 9922:2024". International Organization for Standardization. Archived from the original on 1 April 2025. Retrieved 1 April 2025.
  70. ^ "ISO/IEC TS 19568:2024". International Organization for Standardization. Archived from the original on 25 February 2025. Retrieved 1 April 2025.
  71. ^ B. Stroustrup (interviewed by Sergio De Simone) (30 April 2015). "Stroustrup: Thoughts on C++17 - An Interview". Archived from the original on 8 July 2015. Retrieved 8 July 2015.
  72. ^ Stroustrup, Bjarne (2000). The C++ Programming Language (Special ed.). Addison-Wesley. p. 46. ISBN 0-201-70073-5.
  73. ^ Stroustrup, Bjarne. "Open issues for The C++ Programming Language (3rd Edition)". Archived from the original on 5 May 2014. Retrieved 5 May 2014.
  74. ^ Graziano Lo Russo (2008). "An Interview with A. Stepanov". stlport.org. Archived from the original on 4 March 2009. Retrieved 8 October 2015.
  75. ^ "C++ Core Guidelines". isocpp.github.io. Archived from the original on 16 February 2020. Retrieved 9 February 2020.
  76. ^ "Bjarne Stroustrup announces C++ Core Guidelines : Standard C++". isocpp.org. Archived from the original on 11 May 2020. Retrieved 31 March 2020.
  77. ^ "microsoft/GSL". 18 July 2021. Archived from the original on 18 July 2021. Retrieved 18 July 2021 – via GitHub.
  78. ^ "Using the C++ Core Guidelines checkers". Microsoft Learn. Archived from the original on 13 August 2021. Retrieved 31 March 2020.
  79. ^ "C++ ABI Summary". 20 March 2001. Archived from the original on 10 July 2018. Retrieved 30 May 2006.
  80. ^ "Bjarne Stroustrup's FAQ – Is C a subset of C++?". Archived from the original on 6 February 2016. Retrieved 5 May 2014.
  81. ^ "C9X – The New C Standard". Archived from the original on 21 June 2018. Retrieved 27 December 2008.
  82. ^ "C++0x Support in GCC". Archived from the original on 21 July 2010. Retrieved 12 October 2010.
  83. ^ "C++0x Core Language Features In VC10: The Table". Archived from the original on 21 August 2010. Retrieved 12 October 2010.
  84. ^ "Clang - C++98, C++11, and C++14 Status". Clang.llvm.org. 12 May 2013. Archived from the original on 4 July 2013. Retrieved 10 June 2013.
  85. ^ Bokil, Milind A. (2021). "Writing Assembly Routines within C/C++ and Java Programs". ResearchGate. Retrieved 1 April 2025.
  86. ^ De Vilhena, Paulo Emílio; Lahav, Ori; Vafeiadis, Viktor; Raad, Azalea (2024). "Extending the C/C++ Memory Model with Inline Assembly". Proceedings of the ACM on Programming Languages. 8: 1081–1107. arXiv:2408.17208. doi:10.1145/3689749.
  87. ^ cppreference.com contributors. "asm declaration". cppreference.com. Retrieved 1 April 2025.
  88. ^ "Extended Asm (Using the GNU Compiler Collection)". GCC Online Documentation. GNU Project. Retrieved 1 April 2025.
  89. ^ Intel Corporation. "Inline Assembly". Intel? C++ Compiler Classic Developer Guide and Reference, Version 2021.9. Retrieved 1 April 2025.
  90. ^ IBM. "Inline assembly statements (IBM extension)". IBM Documentation. Retrieved 1 April 2025.
  91. ^ "Inline Assembler Overview". Microsoft Learn. Microsoft. Retrieved 1 April 2025.
  92. ^ "Interfacing C and C++ With Assembly Language". Texas Instruments. Texas Instruments Incorporated. 23 February 2025. Retrieved 1 April 2025.
  93. ^ "C++ to ASM linkage in GCC". OSDev Wiki. Retrieved 1 April 2025.

Further reading

[edit]
[edit]
神是什么 门静脉高压是什么意思 吃什么化痰效果最好最快 涵字属于五行属什么 夏天吃什么降火
叛逆期是什么意思 过敏性皮炎吃什么药 6月6号是什么星座 靶向是什么意思 心态好是什么意思
阳虚什么症状 结婚十一年是什么婚 女人左手心痒预示什么 吃什么食物养胃 易经和周易有什么区别
测脸型适合什么发型 什么药降肌酐 95年的猪是什么命 状元及第是什么意思 什么斗艳
孩子是什么意思hcv8jop4ns9r.cn 天秤座跟什么星座最配cj623037.com 什么是钙化hcv7jop7ns0r.cn 梦见掰玉米是什么意思hcv9jop4ns5r.cn 防晒衣的面料是什么hcv8jop8ns1r.cn
内痔是什么样的图片hcv9jop4ns0r.cn 免冠照片是什么意思hcv9jop1ns7r.cn 老人出汗多是什么原因hcv8jop9ns2r.cn 没落是什么意思hcv9jop0ns1r.cn 诺如病毒拉的大便是什么样的hcv9jop1ns3r.cn
半青皮是什么意思hcv8jop6ns0r.cn 小孩吃什么补脑更聪明hcv9jop6ns8r.cn 甲沟炎看什么科室sscsqa.com 香港买什么便宜hcv8jop1ns0r.cn 骨骼是什么意思0735v.com
飞亚达手表什么档次hcv7jop5ns5r.cn 安大爷是什么意思xianpinbao.com 血沉高是什么病hcv9jop3ns6r.cn 早晨起床口干口苦是什么原因hcv8jop5ns4r.cn 区长什么级别hcv9jop1ns2r.cn
百度