YaaZ / VulkanMemoryAllocator-Hpp

C++ bindings for VulkanMemoryAllocator
Creative Commons Zero v1.0 Universal
55 stars 29 forks source link

Make c++20 module use vulkan_hpp module #33

Open qbojj opened 11 months ago

qbojj commented 11 months ago

Currently vk_mem_alloc.cppm includes vk_mem_alloc.hpp which in turn includes <vulkan/vulkan.hpp>, but it could import the vulkan_hpp module, as if you are using vma-hpp as module you are probably also using vulkan-hpp as a module.

YaaZ commented 7 months ago

Not sure I got your idea. How could we import vulkan_hpp, instead of including <vulkan/vulkan.hpp> in vk_mem_alloc.hpp?

qbojj commented 6 months ago

IDK if it is legal, by You could try

#ifdef VMA_USE_VULKAN_MODULE
import vulkan_hpp;
#else
#include <...>
#endif

I have posted it as a possibility and hadn't thought if it even is possible.

EDIT: as stated in http://eel.is/c++draft/cpp#import-3:

If a pp-import is produced by source file inclusion (including by the rewrite produced when a #include directive names an importable header) while processing the group of a module-file, the program is ill-formed.

so imports in #included files are ill-formed