ABI 稳定性的影响


【Implications of ABI stability】

尽管 Node-API 提供 ABI 稳定性保证,但 Node.js 的其他部分并不保证,且从插件使用的任何外部库也可能没有保证。尤其是,以下任何 API 在主要版本之间都不提供 ABI 稳定性保证:

【Although Node-API provides an ABI stability guarantee, other parts of Node.js do not, and any external libraries used from the addon may not. In particular, none of the following APIs provide an ABI stability guarantee across major versions:】

  • 通过任何以下途径可用的 Node.js C++ API

    #include <node.h>
    #include <node_buffer.h>
    #include <node_version.h>
    #include <node_object_wrap.h> 
  • libuv API 也包含在 Node.js 中,并且可以通过

    #include <uv.h> 
  • 通过 V8 API 提供

    #include <v8.h> 

因此,为了使插件在 Node.js 的主要版本之间保持 ABI 兼容性,它必须仅使用 Node-API,并限制自己使用

【Thus, for an addon to remain ABI-compatible across Node.js major versions, it must use Node-API exclusively by restricting itself to using】

#include <node_api.h> 

并且通过检查它使用的所有外部库,确保这些外部库提供类似于 Node-API 的 ABI 稳定性保证。

【and by checking, for all external libraries that it uses, that the external library makes ABI stability guarantees similar to Node-API.】