Closed GamerSg closed 1 week ago
@asuessenbach we should probably use struct CppType<VkSurfaceKHR, {}>
instead of VK_NULL_HANDLE
in the instantiation. #1860 is relevant here.
We could also use nullptr
as the second template parameter, depending on what you think makes our intentions more explicit.
I'm a bit surprised here about
E:\VulkanSDK\1.3.283.0\Include\vulkan\vulkan_core.h(50,28): note: expanded from macro 'VK_NULL_HANDLE' 50 | #define VK_NULL_HANDLE 0
Why is VK_NULL_HANDLE
defined to be 0
here?
Looking at the code in vulkan_core.h, that can only be when VK_DEFINE_NON_DISPATCHABLE_HANDLE
is already defined:
#ifndef VK_DEFINE_NON_DISPATCHABLE_HANDLE
#if (VK_USE_64_BIT_PTR_DEFINES==1)
#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_MSVC_LANG) && (_MSVC_LANG >= 201103L))
#define VK_NULL_HANDLE nullptr
#else
#define VK_NULL_HANDLE ((void*)0)
#endif
#else
#define VK_NULL_HANDLE 0ULL
#endif
#endif
#ifndef VK_NULL_HANDLE
#define VK_NULL_HANDLE 0
#endif
But regularly, that's done right after that code sequence. Do you have any hint, why it's already defined in your case?
When i mouseover VK_NULL_HANDLE in VS, it shows that it resolves to nullptr. However, it seems when compiling, clang on Windows is resolving it to 0 and producing the error.
Could this inconsistency be due to Intellisense interpreting the code with MSVC compiler? I do not have a clue at this moment as to why it is resolving to 0 with clang.
Incase this is of any help, the only relevant includes before including vulkan.hpp which i think could affect the compilation are the following:
I looked into the SDL includes and see that it is defining VK_DEFINE_NON_DISPATCHABLE_HANDLE
which was causing the issue.
`#if defined(LP64) || defined(_WIN64) || defined(__x86_64) || defined(_M_X64) || defined(ia64) || defined (_M_IA64) || defined(aarch64) || defined(powerpc64)
I've moved the SDL includes after the include to vulkan.hpp and it compiles fine now.
Compiles fine with MSVC compiler on Windows and GCC on Linux. With Clang, im getting multiple errors which look similar,
VulkanSDK\1.3.283.0\Include\vulkan\vulkan_handles.hpp(2482,32): error : conversion from 'int' to 'VkSurfaceKHR' (aka 'VkSurfaceKHR_T *') is not allowed in a converted constant expression 2482 | struct CppType<VkSurfaceKHR, VK_NULL_HANDLE> | ^
~~~~~ E:\VulkanSDK\1.3.283.0\Include\vulkan\vulkan_core.h(50,28): note: expanded from macro 'VK_NULL_HANDLE' 50 | #define VK_NULL_HANDLE 0 | ^