GCC与MS C ++编译器保持API向后兼容二进制 [英] GCC vs MS C++ compiler for maintaining API backwards binary compatibility

查看:185
本文介绍了GCC与MS C ++编译器保持API向后兼容二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我来自Linux世界,并且知道许多关于用C ++语言编写的动态库API的向后兼容性(BC)的文章。其中一个是C ++的策略/二进制兼容性问题,基于 Itanium C ++ ABI ,由GCC编译器使用。但我找不到任何类似的Microsoft C ++编译器(从MSVC)。



我知道大多数技术适用于MS C + +编译器,我会喜欢发现与ABI差异相关的编译器特定问题(v表布局,修改等)。

如下:




  • 你知道MS C ++和GCC编译器在维护BC时有什么区别吗?

  • 在哪里可以找到关于MS C ++ ABI或关于在Windows中维护API的BC的信息?



任何相关信息都将非常感谢。

非常感谢您的帮助!

解决方案

首先,这些策略是一般的,不是仅指gcc。例如:函数中的私有/公共标记是特定于MSVC而不是gcc的。



因此,基本上这些规则完全适用于MSVC和一般编译器。 p>

但是...



您应该记住:


  1. 自从3.4发布以来,GCC / C ++保持其ABI稳定,并且大约为7年(从2004年开始),而MSVC在每个主要版本中都取消了ABI:MSVC8(2005),MSVC9(2008),MSVC10 )不相容。

  2. 一些经常使用MSVC的标记可能会破坏ABI(例如Exceptions模型)

  3. MSVC不兼容的运行


  4. 所以是的,你可以使用这些规则,但正如在MSVC的通常情况下,它有更多的



    另请参阅二进制兼容性的一些想法和Qt保持他们ABI稳定与MSVC以及。 b
    $ b

    注意我有一些经验,因为我遵守这些规则在 CppCMS


    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).

    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:

    • Do you know any differences between MS C++ and GCC compilers when maintaining BC?
    • Where can I find information about MS C++ ABI or about maintaining BC of API in Windows?

    Any related information will be highly appreciated.
    Thanks a lot for your help!

    解决方案

    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.

    So basically these rules are fully applicable to MSVC and general compiler as well.

    But...

    You should remember:

    1. GCC/C++ keeps its ABI stable since 3.4 release and it is about 7 years (since 2004) while MSVC breaks its ABI every major release: MSVC8 (2005), MSVC9 (2008), MSVC10 (2010) are not compatible with each other.
    2. Some frequently flags used with MSVC can break ABI as well (like Exceptions model)
    3. MSVC has incompatible run-times for Debug and Release modes.

    So yes you can use these rules, but as in usual case of MSVC it has much more quirks.

    See also "Some thoughts on binary compatibility" and Qt keeps they ABI stable with MSVC as well.

    Note I have some experience with this as I follow these rules in CppCMS

    这篇关于GCC与MS C ++编译器保持API向后兼容二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆