Skip to content

Problems when using Modules #84

@Chery-cake

Description

@Chery-cake

When trying to use modules i get a list of errors and warnings like this:

/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:16533:18: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
 16533 |     VmaAllocation* pAllocation,
       |                  ^
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:16533:18: note: insert '_Nullable' if the pointer may be null
 16533 |     VmaAllocation* pAllocation,
       |                  ^
       |                    _Nullable
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:16533:18: note: insert '_Nonnull' if the pointer should never be null
 16533 |     VmaAllocation* pAllocation,
       |                  ^
       |                    _Nonnull
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:16534:22: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
 16534 |     VmaAllocationInfo* pAllocationInfo)
       |                      ^
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:16534:22: note: insert '_Nullable' if the pointer may be null
 16534 |     VmaAllocationInfo* pAllocationInfo)
       |                      ^
       |                        _Nullable
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:16534:22: note: insert '_Nonnull' if the pointer should never be null
 16534 |     VmaAllocationInfo* pAllocationInfo)
       |                      ^
       |                        _Nonnull
.
.
.
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:10120:14: note: in instantiation of member function 'VmaPoolAllocator<VmaAllocation_T>::~VmaPoolAllocator' requested here
 10120 |     explicit VmaAllocationObjectAllocator(const VkAllocationCallbacks* pAllocationCallbacks)
       |              ^
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:4210:5: error: no matching function for call to 'VmaFree'
 4210 |     VmaFree(pAllocationCallbacks, ptr);
      |     ^~~~~~~
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:10207:5: note: in instantiation of function template specialization 'vma_delete<VmaBlockMetadata>' requested here
 10207 |     vma_delete(GetAllocationCallbacks(), m_Metadata);
       |     ^
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:10640:9: error: no matching function for call to 'VmaFree'
 10640 |         VmaFree(hAllocator, ptr);
       |         ^~~~~~~
/build/_deps/_vma_hpp-src/VulkanMemoryAllocator/include/vk_mem_alloc.h:10721:5: note: in instantiation of function template specialization 'vma_delete<VmaBlockMetadata>' requested here
 10721 |     vma_delete(allocator, m_pMetadata);
       |     ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
838 warnings and 20 errors generated.

Changing the module declaration from this:

// Generated from the Vulkan Memory Allocator (vk_mem_alloc.h).
module;
#define VMA_HPP_CXX_MODULE
#define VMA_IMPLEMENTATION
#include "vk_mem_alloc.hpp"
#include "vk_mem_alloc_raii.hpp"
export module vk_mem_alloc;
export import vulkan;

to this:

// Generated from the Vulkan Memory Allocator (vk_mem_alloc.h).
module;
#include "vk_mem_alloc.hpp"
#include "vk_mem_alloc_raii.hpp"
export module vk_mem_alloc;
export import vulkan;
#define VMA_HPP_CXX_MODULE
#define VMA_IMPLEMENTATION

Solves all the problems.

I'm using clang 22.1.5 on linux.

This is my cmake config to import the library:

FetchContent_Declare(
    _vma_hpp
    GIT_REPOSITORY https://github.com/YaaZ/VulkanMemoryAllocator-Hpp.git
    GIT_TAG v3.3.0+3
    GIT_SHALLOW TRUE
)
set(VMA_STATIC_VULKAN_FUNCTIONS OFF CACHE BOOL "" FORCE)
set(VMA_DYNAMIC_VULKAN_FUNCTIONS ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(_vma_hpp)

add_library(vma INTERFACE)
target_link_libraries(vma INTERFACE
  vulkan
  VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-Hpp
  VulkanMemoryAllocator-Hpp::VulkanMemoryAllocator-HppModule
)
target_compile_definitions(vma INTERFACE
    VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=1
    VMA_STATIC_VULKAN_FUNCTIONS=0
    VMA_DYNAMIC_VULKAN_FUNCTIONS=1
)
set_target_properties(vma PROPERTIES
    POSITION_INDEPENDENT_CODE ON
    CXX_VISIBILITY_PRESET default
    VISIBILITY_INLINES_HIDDEN OFF
    WINDOWS_EXPORT_ALL_SYMBOLS ON
    CXX_MODULE_STD ON
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions