我是Linux系统编程的新手,在阅读时遇到了API和ABI
Linux系统编程。
API的定义:
API定义了接口
一个软件进行通信
与另一个在源级。
ABI的定义:
而API定义了一个源
接口时,ABI定义了
两个之间的低级二进制接口
或者更多的软件
特定的体系结构。它定义了
应用程序如何与
本身,应用程序如何交互
与内核,以及如何一个
应用程序与库交互。
程序如何在源级进行通信?什么是源级别?它是否与源代码有关?或者库的源代码包含在主程序中?
我所知道的唯一区别是API主要由程序员使用,而ABI主要由编译器使用。
API是人类使用的。我们编写源代码。当我们编写程序并想要使用一些库函数时,我们编写如下代码:
long howManyDecibels = 123L;
int ok = livenMyHills(howManyDecibels);
and we needed to know that there is a method livenMyHills(), which takes a long integer parameter. So as a Programming Interface it's all expressed in source code. The compiler turns this into executable instructions which conform to the implementation of this language on this particular operating system. And in this case result in some low level operations on an Audio unit. So particular bits and bytes are squirted at some hardware. So at runtime there's lots of Binary level action going on which we don't usually see.
在二进制级别,必须对在二进制级别传递的字节有一个精确的定义,例如4字节整数中的字节顺序,或者复杂数据结构的布局——是否有填充字节来对齐一些值。这个定义就是ABI。