我正在研究Khronos openvx的进出口扩展。当我读vx_import.h文件时
VX_API_ENTRY vx_status VX_API_CALL vxReleaseImport(vx_import *import); 函数。
我想了解为什么他们在函数中编写了VX_API_ENTRY和VX_API_CALL。
我是开公司的新手。如果有人知道这一点,请回答。
发布于 2018-09-07 08:27:21
在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)上代码可能会失败。
https://stackoverflow.com/questions/52218062
复制相似问题