【问题标题】:What is VX_API_ENTRY and VX_API_CALL in Khronos openvx standard?Khronos openvx 标准中的 VX_API_ENTRY 和 VX_API_CALL 是什么?
【发布时间】:2018-09-07 08:04:38
【问题描述】:

我正在研究 Khronos openvx 的导入导出扩展。在阅读我看到的vx_import.h 文件时

VX_API_ENTRY vx_status VX_API_CALL vxReleaseImport(vx_import *import);  

功能。

我想了解他们为什么在函数中写了VX_API_ENTRYVX_API_CALL

我是 openvx 的新手。如果有人知道请回复。

【问题讨论】:

    标签: c++ c openvx


    【解决方案1】:

    vx_types.h 标头中您可以阅读:

    /*!
     * \internal
     * \def VX_API_ENTRY
     * \brief This is a tag used to identify exported, public API functions as
     * distinct from internal functions, helpers, and other non-public interfaces.
     * It can optionally be defined in the make system according the the compiler and intent.
     * \ingroup group_basic_features
     */
    
    /*!
     * \def VX_API_CALL
     * \brief Defines calling convention for OpenVX API.
     * \ingroup group_basic_features
     */
    
    /*!
     * \def VX_CALLBACK
     * \brief Defines calling convention for user callbacks.
     * \ingroup group_basic_features
     */
    

    然后,VX_API_ENTRY 定义为空,VX_API_CALL 在 Windows 上定义为 __stdcall,否则为空。

    它们有什么用?嗯,这些是指定 API 的调用约定,同时,正如评论所说,记录哪些函数实际上是公共的。

    例如,在 Windows 中,来自 DLL 的公共函数有时会以 declspec(__dllimport) 为前缀,以指示编译器使用导入函数表,您的构建系统可以为此定义 VX_API_ENTRY

    __stdcall 是这个库使用的调用约定。通常你不指定它,让编译器选择默认值。但在公共 DLL 中,最好不要过多依赖默认值,因为 DLL 编译器和 EXE 编译器可能使用不同的值,这会破坏链接。

    但大多数情况下,作为 API 的最终用户,您可以忽略它们,它们正常工作。

    VX_CALLBACK 除外!您必须将回调声明为VX_CALLBACK,否则您的代码可能会在某些架构(主要是 Windows)上失败。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-26
      • 2011-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多