问题描述
我来自 Linux 世界,知道很多关于维护用 C++ 语言编写的动态库 API 的向后二进制兼容性 (BC) 的文章.其中之一是C++ 的政策/二进制兼容性问题"http://www.codesourcery.com/public/cxx-abi/abi.html" rel="noreferrer">Itanium C++ ABI,由 GCC 编译器使用.但是我找不到与 Microsoft C++ 编译器(来自 MSVC)类似的东西.
I came from the Linux world and know a lot of articles about maintaining backwards binary compatibility (BC) of a dynamic library API written in C++ language. One of them is "Policies/Binary Compatibility Issues With C++" based on the Itanium C++ ABI, which is used by the GCC compiler. But I can't find anything similar for the Microsoft C++ compiler (from MSVC).
我知道大多数技术都适用于 MS C++ 编译器,我想发现与 ABI 差异(v-table 布局、修改等)相关的编译器特定问题
I understand that most of the techniques are applicable to the MS C++ compiler and I would like to discover compiler-specific issues related to ABI differences (v-table layout, mangling, etc.)
那么,我的问题如下:
So, my questions are the following:
- 在维护 BC 时,您知道 MS C++ 和 GCC 编译器之间有什么区别吗?
- 在哪里可以找到有关 MS C++ ABI 或在 Windows 中维护 API BC 的信息?
任何相关信息将不胜感激.
非常感谢您的帮助!
Any related information will be highly appreciated.
Thanks a lot for your help!
推荐答案
首先,这些政策是通用的,不仅仅针对 gcc.例如:函数中的私有/公共标记是特定于 MSVC 而不是 gcc.
First of all these policies are general and not refer to gcc only. For example: private/public mark in functions is something specific to MSVC and not gcc.
所以基本上这些规则完全适用于 MSVC 和通用编译器.
So basically these rules are fully applicable to MSVC and general compiler as well.
可是……
你应该记住:
- GCC/C++ 自 3.4 版本以来一直保持其 ABI 稳定,大约 7 年(自 2004 年以来),而 MSVC 在每个主要版本中都打破了其 ABI:MSVC8 (2005)、MSVC9 (2008)、MSVC10 (2010) 与彼此.
- 与 MSVC 一起使用的一些常用标志也会破坏 ABI(如异常模型)
- MSVC 的调试和发布模式的运行时间不兼容.
所以是的,您可以使用这些规则,但与通常的 MSVC 情况一样,它有更多的怪癖.
So yes you can use these rules, but as in usual case of MSVC it has much more quirks.
另见关于二进制兼容性的一些想法" 和 Qt 也通过 MSVC 使它们的 ABI 保持稳定.
See also "Some thoughts on binary compatibility" and Qt keeps they ABI stable with MSVC as well.
注意我在这方面有一些经验,因为我遵循 CppCMS
Note I have some experience with this as I follow these rules in CppCMS
这篇关于用于维护 API 向后二进制兼容性的 GCC 与 MS C++ 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!