API 與 ABI 的具體含義

API都明白什麼意思,最近總看到ABI,不太明白意思,搜一搜,原來如此!


轉至http://blog.chinaunix.net/uid-14735472-id-111116.html

api 是應用程序和操作系統之間的接口,凡是符合該api標準的應用程序都可以在支持該api的操作系統上編譯通過。

abi 是二進制級別的接口,規定了二進制文件的格式、內容、裝載/卸載程序的要求、函數調用時的參數傳遞

規則、寄存器、堆棧的使用。
如果操作系統都支持該api,但是機器的體系結構不同即他們的abi不同,那麼在一個機器上生成的二進制代碼是不可以在另外一臺機器上面運行成功的,可能因爲函數調用的參數傳遞規則不同或者其他由abi定義的行爲產生的差異性。
其實關鍵的是
abi定義了運行時的兼容性問題,這個問題是api無法解決的。api所能解決的是靜態狀態下的兼容性問題。

以下摘自encyclopedia of PCMAGZINE

Definition of: API 
(Application Programming Interface) A language and message format used by an application program to communicate with the operating system or some other control program such as a database management system (DBMS) or communications protocol. APIs are implemented by writing function calls in the program, which provide the linkage to the required subroutine for execution. Thus, an API implies that some program module is available in the computer to perform the operation or that it must be linked into the existing program to perform the tasks.

Definition of ABI

(Application Binary Interface) A specification for a specific hardware platform combined with the operating system. It is one step beyond the application program interface (API), which defines the calls from the application to the operating system. The ABI defines the API plus the machine language for a particular CPU family. An API does not ensure runtime compatibility, but an ABI does, because it defines the machine language, or runtime, format.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章