VKAPI_ATTR and VKAPI_CALL macros in Vulkan

守給你的承諾、 提交于 2019-12-31 02:13:16

问题


I have been searching and I still am not sure what VKAPI_ATTR and VKAPI_CALL are. I am not sure if they are suppose to be a macro or some fancy C++ function declaration I am not aware of.

What is VKAPI_ATTR void VKAPI_CALL vkCommand(void) offering that void vkCommand(void) doesn't offer?


回答1:


They are macros to make sure the correct calling convention is applied. This is less important in 64 bit where they have mostly converged but in 32 bit there are several incompatible ones.

Unfortunately different compilers have different ways of doing that. One puts the required token before the return value the other puts it after.

So the header uses both to make sure it can cover all bases.




回答2:


They are defined in vk_platform.h.

They are C preprocessor macros that expand to platform-dependent (and often compiler-specific) function attributes.

The spec defines what they are supposed to do.
But basically each of VKAPI_ATTR, VKAPI_CALL and VKAPI_PTR is distiguished by the spot it has to be in the function declaration to satisfy the C (potentially compiler-dependent) syntax.
Their value(s) are things like the chosen calling convention (e.g. __stdcall) for the platform (detected at compile time).



来源:https://stackoverflow.com/questions/43668656/vkapi-attr-and-vkapi-call-macros-in-vulkan

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!