C|应用程序编程接口(API)及其实现(Implementation)

A library implements a collection of functions and definitions that can be used by other programs. A C library consists of two parts:

库实现了可由其他程序使用的函数和定义的集合。C库由两部分组成:

The application programming interface (API) to the library, which gets defined in one or more header files (.h files) that must be included in C source code files that plan to use the library. The headers define what the library exports to its users. These definitions usually include library function prototypes, and they may also include type, constant, or global variable declarations.

库的应用程序编程接口(API),它在一个或多个头文件(.h文件)中定义,这些头文件必须包含在计划使用库的C源代码文件中。头文件定义了库导出给用户的内容。这些定义通常包括库函数原型,也可能包括类型、常量或全局变量声明。

The implementation of the library’s functionality, often made available to programs in a precompiled binary format that gets linked (added) into the binary executable created by gcc. Precompiled library code might be in an archive file (libsomelib.a, archive) containing several .o files that can be statically linked into the executable file at compile time. Alternatively, it may consist of a shared object file (libsomelib.so, shared object) that can be dynamically linked at runtime into a running program.

库功能的实现,通常以预编译的二进制格式提供给程序,该格式链接(添加)到gcc创建的二进制可执行文件中。预编译的库代码可能位于包含多个.o文件的存档文件(libsomelib.a, archive)中,这些文件可以在编译时静态链接到可执行文件。或者,它可以由一个共享对象文件(libsomelib.so, shared object)组成,该文件可以在运行时动态链接到正在运行的程序中。

For example, the C string library implements a set of functions to manipulate C strings. The string.h header file defines its interface, so any program that wants to use string library functions must #include <string.h>. The implementation of the C string library is part of the larger standard C library (libc) that the gcc compiler automatically links into every executable file it creates.

例如,C字符串库实现了一组操作C字符串的函数。字符串.h头文件定义了它的接口,因此任何想要使用字符串库函数的程序都必须包含<string.h>。C字符串库的实现是更大的标准C库(libc)的一部分,gcc编译器会自动链接到它创建的每个可执行文件中。

A library’s implementation consists of one or more modules (.c files), and may additionally include header files that are internal to the library implementation; internal header files are not part of the library’s API but are part of well-designed, modular library code. Often the C source code implementation of a library is not exported to the user of the library. Instead, the library is made available in a precompiled binary form. These binary formats are not executable programs (they cannot be run on their own), but they provide executable code that can be linked into (added into) an executable file by gcc at compilation time.

库的实现由一个或多个模块(.c文件)组成,还可以包括库实现内部的头文件;内部头文件不是库API的一部分,而是精心设计的模块化库代码的一部分。库的C源代码实现通常不会导出到库的用户。相反,该库是以预编译的二进制形式提供的。这些二进制格式不是可执行程序(它们不能自己运行),但它们提供了可执行代码,可由gcc在编译时链接到(添加到)可执行文件中。

ref

https://diveintosystems.org/

-End-

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。

(0)
上一篇 2023年3月20日 上午8:53
下一篇 2023年3月20日 上午9:03

相关推荐

  • 景德镇管理中心抓细抓实国检内业资料质量

    随着国检时间的日益临近,景德镇管理中心按照迎“国检”工作的有关要求,进一步加强内业资料整理、细化、分类、归档工作,做到内业资料“标准化、规范化、精细化、考核化、特色化”。 资料整理…

    科研百科 2023年1月13日
    336
  • 叶城县畜牧养殖让农民“钱袋子”鼓起来

      天山网讯(通讯员黄艳报道)2015年以来,叶城县坚持以市场为导向,以效益为中心,积极探索先进畜牧业生产模式,狠抓动物疫病防治,加大养殖小区建设力度,规模养殖户示范带动作用发挥明…

    科研百科 2022年6月1日
    433
  • 永川区交通局机关党总支:打造“红动交通·开路先锋”品牌 为交通强区建设赋能

    党旗所指,他们全力以赴;抢通道路,他们义不容辞;疫情防控,他们冲锋在前…… 他们,就是永川区交通局机关党总支。 近年来,永川区交通局机关党总支始终把党建与交…

    科研百科 2023年6月11日
    266
  • 重庆卫健委科研申报通知

    重庆卫健委科研申报通知 尊敬的各位同事: 大家好!近期,重庆卫健委发布了关于科研申报的通知,为了帮助大家更好地开展科研工作,我们特别制定了以下通知。 一、申报对象 本次申报对象为重…

    科研百科 2024年10月11日
    13
  • 柯坦镇:桔杆作饲料 牛羊好过冬

      12月8日下午,柯坦镇“高山养殖农场” 场主束传军,正在刚收割的双晚田里用牛拉、人挑,将农户免费提供的新鲜桔杆堆积、打捆运回农场人作牛羊过冬饲料。这是该…

    科研百科 2022年6月1日
    362
  • 退出科技部项目的申请书2867704660

    尊敬的科技部领导: 我谨向科技部申请退出其资助的项目。 我在此声明,我将不再参与该项目。该项目与我的个人目标和职业规划不符,我已经无法胜任该项目的要求。 在我参与该项目期间,我受到…

    科研百科 2024年10月18日
    7
  • 学校软弱涣散党组织整顿方案

    学校软弱涣散党组织整顿方案 近年来,随着教育事业的发展和改革,学校党组织的重要性越来越受到重视。然而,在一些学校中,党组织的软弱涣散问题仍然存在,这严重影响了学校的工作和发展。为了…

    科研百科 2024年11月5日
    6
  • 西固区金沟乡创新“1234”工作思路 提升监督执纪效能

    西固区金沟乡纪委紧贴工作实际,积极创新监督理念思路和方式方法,探索“1234”工作思路,推动各项重点工作任务高效落实。 创新一套工作机制。坚持把全面从严治党牢牢抓在手上、扛在肩上、…

    2022年7月2日
    335
  • 党校课题经费管理办法

    党校课题经费管理办法 为规范党校课题经费管理,提高课题经费使用效率,确保课题经费主要用于教学和科研活动,我们制定了党校课题经费管理办法。 办法共九章,主要包括适用范围、经费预算、经…

    科研百科 2024年7月12日
    50
  • 比较好的施工进度计划软件

    好的施工进度计划软件 随着建筑行业的发展,施工进度计划软件已经成为了一个非常重要的工具。一个好的施工进度计划软件可以帮助项目经理、设计师、工程师和施工团队更好地管理项目,确保项目按…

    科研百科 2024年8月31日
    38