Difference between API and ABI

前端 未结 9 2037
余生分开走
余生分开走 2020-12-04 04:34

I am new to linux system programming and I came across API and ABI while reading Linux System Programming.

Definition of API :

9条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-04 04:57

    I mostly come across these terms in the sense of an API-incompatible change, or an ABI-incompatible change.

    An API change is essentially where code that would have compiled with the previous version won't work anymore. This can happen because you added an argument to a function, or changed the name of something accessible outside of your local code. Any time you change a header, and it forces you to change something in a .c/.cpp file, you've made an API-change.

    An ABI change is where code that has already been compiled against version 1 will no longer work with version 2 of a codebase (usually a library). This is generally trickier to keep track of than API-incompatible change since something as simple as adding a virtual method to a class can be ABI incompatible.

    I've found two extremely useful resources for figuring out what ABI compatibility is and how to preserve it:

    • The list of Do's and Dont's with C++ for the KDE project
    • Ulrich Drepper's How to Write Shared Libraries.pdf (primary author of glibc)

提交回复
热议问题