Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan.cppm fails to compile on 1.4.304.0 #2045

Open
Hisukedema opened this issue Jan 15, 2025 · 2 comments
Open

Vulkan.cppm fails to compile on 1.4.304.0 #2045

Hisukedema opened this issue Jan 15, 2025 · 2 comments

Comments

@Hisukedema
Copy link

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()
@noir-nik
Copy link

I can confrm this. The module only compiles when line 2701 is commented or replaced with

using ::PFN_vkVoidFunction;

The error code generated with clang:

D:/VulkanSDK/1.4.304.0/Include/vulkan/vulkan.cppm:2701:9: error: no member named 'PFN_VoidFunction' in namespace 'vk'; did you mean '::PFN_vkVoidFunction'?
 2701 |   using VULKAN_HPP_NAMESPACE::PFN_VoidFunction;
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         ::PFN_vkVoidFunction
D:\VulkanSDK\1.4.304.0\Include/vulkan/vulkan_hpp_macros.hpp:220:32: note: expanded from macro 'VULKAN_HPP_NAMESPACE'
  220 | #  define VULKAN_HPP_NAMESPACE vk
      |                                ^
D:\VulkanSDK\1.4.304.0\Include/vulkan/vulkan_core.h:3122:26: note: '::PFN_vkVoidFunction' declared here
 3122 | typedef void (VKAPI_PTR *PFN_vkVoidFunction)(void);

@asuessenbach
Copy link
Contributor

Or as a hotfix add this to vulkan_handles.hpp:

typedef void( VKAPI_PTR * PFN_VoidFunction )();

This missing typedef has been added by #2033, but apparently that change hasn't made it into the 304 release of the VulkanSDK. I'm so sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants