Skip to content

Vulkan.cppm fails to compile on 1.4.304.0 #2045

@Hisukedema

Description

@Hisukedema

When compiling in Visual Studio (MSVC), the following error is produced:

------ Build started: Project: VulkanHppModuleLib, Configuration: Debug x64 ------
Scanning sources for module dependencies...
Compiling...
vulkan.cppm
C:\VulkanSDK\1.4.304.0\Include\vulkan\vulkan.cppm(2701,31): error C2039: 'PFN_VoidFunction': is not a member of 'vk'
C:\VulkanSDK\1.4.304.0\Include\vulkan\vulkan.cppm(29,18): see declaration of 'vk'
C:\VulkanSDK\1.4.304.0\Include\vulkan\vulkan.cppm(2701,3): error C2873: 'PFN_VoidFunction': symbol cannot be used in a using-declaration
Done building project "VulkanHppModuleLib.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Commenting out line 2701 of Vulkan.cppm fixes the issue and allows compilation.

The visual studio project was generated with this cmake code:

function (VE_Create_Vulkan_hpp_module)

    # find Vulkan SDK
    find_package( Vulkan REQUIRED )

    # Require Vulkan version ≥ 1.3.256 (earliest version when the Vulkan module was available)
    if( ${Vulkan_VERSION} VERSION_LESS "1.3.256" )
      message( FATAL_ERROR "Minimum required Vulkan version for C++ modules is 1.3.256. "
               "Found ${Vulkan_VERSION}."
      )
    endif()

    message(STATUS "Vulkan_INCLUDE_DIR='${Vulkan_INCLUDE_DIR}'")

    add_library( VulkanHppModuleLib )

    target_sources( VulkanHppModuleLib PRIVATE
     FILE_SET CXX_MODULES
     BASE_DIRS ${Vulkan_INCLUDE_DIR}
     FILES "${Vulkan_INCLUDE_DIR}/vulkan/vulkan.cppm"
    )

    target_include_directories(VulkanHppModuleLib
            PUBLIC 
                "${Vulkan_INCLUDE_DIR}"
    )

    target_compile_features( VulkanHppModuleLib PUBLIC cxx_std_23 )
    target_link_libraries( VulkanHppModuleLib PUBLIC Vulkan::Vulkan )

endfunction()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions