NDK 中的 Unified Headers 记录

NDK 修订历史查看:NDK Revision History

ndk-r14 release note 关于 Unified Headers 的说明

文档原文:

  • Unified headers: This release introduces platform headers that are synchronized and kept always up-to-date and accurate with the Android platform. Header-only bug fixes now affect all API levels. The introduction of unified headers fixes inconsistencies in earlier NDK releases, such as:
    • Headers in M and N were actually headers for L.
    • Function declarations in headers did not match their platform levels correctly; headers declared non-existent functions or failed to declare available functions.
    • Several of the old API levels had missing or incorrect constants that were in newer API levels.

These new unified headers are not enabled by default. To learn how to enable and use these headers, see Unified Headers.

参考翻译:

  • 统一头文件:此版本引入了平台头文件,这些头文件与Android平台同步并始终保持最新且准确。现在,仅标头的错误修复会影响所有API级别。统一标头的引入解决了NDK早期版本中的不一致问题,例如:
    • M和N中的头文件实际上是L的标头。
    • 头文件中的函数声明与平台级别不正确匹配;标头声明了不存在的函数或未声明可用的函数。
    • 几个旧的API级别缺少更新的API级别中的常量或缺少这些常量。

这些新的统一头文件默认情况下未启用。要了解如何启用和使用这些标题,请参阅 Unified Headers

Unified Headers 文档

文档原文:

Issue #120

Before NDK r14, we had a set of libc headers for each API version. In many cases these headers were incorrect. Many exposed APIs that didn‘t exist, and others didn’t expose APIs that did.
In NDK r14 (as an opt in feature) we unified these into a single set of headers, called unified headers. This single header path is used for every platform level. API level guards are handled with #ifdef. These headers can be found in [prebuilts/ndk/platform/sysroot].
Unified headers are built directly from the Android platform, so they are up to date and correct (or at the very least, any bugs in the NDK headers will also be a bug in the platform headers, which means we’re much more likely to find them).
In r15 unified headers are used by default. In r16, the old headers have been removed.

Supporting Unified Headers in Your Build System

See the Build System Maintainers doc.

参考翻译:
在NDK r14之前,每个API版本都有一组libc头文件。在许多情况下,这些头文件不正确。许多对外公开的API实际不存在,其他未公开的API也是这样。

在NDK r14(作为可选功能)中,我们将它们统一为一组头文件,称为统一头文件(Unified Headers)。这组头文件路径用于每个平台级别。API级别防护使用 #ifdef 来处理。这些头文件可以在 ndk-dir/sysroot/usr/include 中找到。
笔者注:这里英文原文档中说的 prebuilts/ndk/platform/sysroot 这个路径是不对的,实际应该是在ndk-dir/sysroot,这一点通过对比 NDK r13和 NDK r14版本的目录结构就可以知道:
在这里插入图片描述

统一头文件是直接从Android平台构建的,因此它们是最新且正确的(或者至少,NDK标头中的任何错误也将是平台标头中的错误,这意味着我们更有可能找到他们)。

在r15中,默认情况下使用统一头文件。在r16中,旧的头文件已被删除。

在构建系统中支持统一头,请参考构建系统维护者文档。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值