我在查看 C++ 的 GCC 手册时,发现了以下引述:
Version 0 refers to the version conforming most closely to the C++ ABI specification. Therefore, the ABI obtained using version 0 will change in different versions of G++ as ABI bugs are fixed. (source)
可以看出,上述段落引用了某种看似标准的 C++ ABI。然而,据我了解,不存在这样的 ABI。这段话在说什么?一个好的答案将给出尽可能详尽的解释。将“C++ ABI 规范”放入我首选的搜索引擎中没有任何用处。
最佳答案
从WG21的提案中可以看出N4028 Defining a Portable C++ ABI gcc 指的是 Common Vendor ABI (Itanium C++ ABI) :
Existing Practice
Examples of existing practice include:
- The Common Vendor ABI (Itanium C++ ABI) is a step in this direction, to specify an ABI for the language on some platforms. It is supported today by compilers such as GCC and EDG. It does not specify an ABI for the standard library, so this is necessary but insufficient to, for example, use
std::string
on a stable API boundary- Microsoft VC++ likewise has long had a de facto stable, though undocumented, ABI for the language. It does not have a stable ABI for the standard library, but rather intentionally breaks ABI compatibility on every major release, for example in order to allow continuous improvements to the implementation and to quickly implement a new standard library that contains ABI breaking changes.
- ...
gcc 在他们的 ABI Policy and Guidelines 中也介绍了这一点:
... Furthermore, C++ source that is compiled into object files is transformed by the compiler: it arranges objects with specific alignment and in a particular layout, mangling names according to a well-defined algorithm, has specific arrangements for the support of virtual functions, etc. These details are defined as the compiler Application Binary Interface, or ABI. From GCC version 3 onwards the GNU C++ compiler uses an industry-standard C++ ABI, the Itanium C++ ABI. ...
关于c++ - GCC 手册中提到的 "C++ ABI Specification"是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52903807/