D.4. Platform-Specific Macro Definitions in vk_platform.h

Additional platform-specific macros and interfaces are defined using the included vk_platform.h file. These macros are used to control platform-dependent behavior, and their exact definitions are under the control of specific platforms and Vulkan implementations.

D.4.1. Platform-Specific Calling Conventions

On many platforms the following macros are empty strings, causing platform- and compiler-specific default calling conventions to be used.

VKAPI_ATTR is a macro placed before the return type in Vulkan API function declarations. This macro controls calling conventions for C++11 and GCC/Clang-style compilers.

VKAPI_CALL is a macro placed after the return type in Vulkan API function declarations. This macro controls calling conventions for MSVC-style compilers.

VKAPI_PTR is a macro placed between the ( and * in Vulkan API function pointer declarations. This macro also controls calling conventions, and typically has the same definition as VKAPI_ATTR or VKAPI_CALL, depending on the compiler.

D.4.2. Platform-Specific Header Control

If the VK_NO_STDINT_H macro is defined by the application at compile time, extended integer types used by vulkan.h, such as uint8_t, must also be defined by the application. Otherwise, vulkan.h will not compile. If VK_NO_STDINT_H is not defined, the system <stdint.h> is used to define these types, or there is a fallback path when Microsoft Visual Studio version 2008 and earlier versions are detected at compile time.

D.4.3. Window System-Specific Header Control

To use a Vulkan extension supporting a platform-specific window system, header files for that window systems must be included at compile time. The Vulkan header files cannot determine whether or not an external header is available at compile time, so applications wishing to use such an extension must #define a macro causing such headers to be included. If this is not done, the corresponding extension interfaces will not be defined and they will be unusable.

The extensions, required compile time symbols to enable them, window systems they correspond to, and external header files that are included when the macro is #defined are shown in the following table.

Table D.1. Window System Extensions and Required Compile Time Symbol Definitions

Extension Name Required Compile Time Symbol Window System Name External Header Files Used

VK_KHR_android_surface

VK_USE_PLATFORM_ANDROID_KHR

Android Native

<android/native_window.h>

VK_KHR_mir_surface

VK_USE_PLATFORM_MIR_KHR

Mir

<mir_toolkit/client_types.h>

VK_KHR_wayland_surface

VK_USE_PLATFORM_WAYLAND_KHR

Wayland

<wayland-client.h>

VK_KHR_win32_surface

VK_USE_PLATFORM_WIN32_KHR

Microsoft Windows

<windows.h>

VK_KHR_xcb_surface

VK_USE_PLATFORM_XCB_KHR

X Window System Xcb library

<xcb/xcb.h>

VK_KHR_xlib_surface

VK_USE_PLATFORM_XLIB_KHR

X Window System Xlib library

<X11/Xlib.h>