API 和 ABI 的区别 [英] Difference between API and ABI

查看:36
本文介绍了API 和 ABI 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Linux 系统编程的新手,在阅读时遇到了 API 和 ABILinux 系统编程.

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

API 的定义:

API 定义了接口,通过这些接口一个软件通信与另一个在源级别.

An API defines the interfaces by which one piece of software communicates with another at the source level.

ABI 的定义:

而 API 定义了一个源接口,ABI 定义了两个之间的低级二进制接口或多个软件在一个特定的架构.它定义了应用程序如何与本身,应用程序如何交互与内核,以及如何应用程序与库交互.

Whereas an API defines a source interface, an ABI defines the low-level binary interface between two or more pieces of software on a particular architecture. It defines how an application interacts with itself, how an application interacts with the kernel, and how an application interacts with libraries.

程序如何在源代码级别进行通信?什么是源级别?它与源代码有任何关系吗?或者库的来源被包含在主程序中?

How can a program communicate at a source level? What is a source level? Is it related to source code in any way? Or the source of the library gets included in the main program?

我知道的唯一区别是 API 主要由程序员使用,而 ABI 主要由编译器使用.

The only difference I know is API is mostly used by programmers and ABI is mostly used by a compiler.

推荐答案

API 是人类使用的.我们编写源代码.当我们编写程序并想要使用一些库函数时,我们会编写如下代码:

The API is what humans use. We write source code. When we write a program and want to use some library function we write code like:

 long howManyDecibels = 123L;
 int ok = livenMyHills( howManyDecibels);

而且我们需要知道有一个方法 livenMyHills(),它接受一个长整数参数.所以作为一个编程接口,它都用源代码来表达.编译器将其转换为可执行指令,这些指令符合该特定操作系统上该语言的实现.在这种情况下,会导致音频单元上的一些低级操作.所以特定的位和字节会在某些硬件上喷出.所以在运行时会发生很多我们通常看不到的二进制级别的动作.

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.

这篇关于API 和 ABI 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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