Skip to content

Commit 8219a21

Browse files
committed
Work around gcc-8 warning with GetProcAddress
On MinGW starting from gcc-8, casting FARPROC returned by GetProcAddress produces the following warning: cast between incompatible function types from 'FARPROC' {aka 'long long int ()()'} to 'void ( (*)(struct VkInstance_T *, const char *))(void)' This change works around it by casting through a void(*)(void) type, which seems to be the idiomatic way to silence this. Fixes zeux#19.
1 parent c75222e commit 8219a21

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

volk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ VkResult volkInitialize(void)
3333
if (!module)
3434
return VK_ERROR_INITIALIZATION_FAILED;
3535

36-
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)GetProcAddress(module, "vkGetInstanceProcAddr");
36+
// note: function pointer is cast through void function pointer to silence cast-function-type warning on gcc8
37+
vkGetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)(void(*)(void))GetProcAddress(module, "vkGetInstanceProcAddr");
3738
#elif defined(__APPLE__)
3839
void* module = dlopen("libvulkan.dylib", RTLD_NOW | RTLD_LOCAL);
3940
if (!module)

0 commit comments

Comments
 (0)