Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
720 views
in Technique[技术] by (71.8m points)

visual c++ - GCC vs MS C++ compiler for maintaining API backwards binary compatibility

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...