From 1b12dd8cbbc95d01a6c4ace12abce66d3e0e78b8 Mon Sep 17 00:00:00 2001 From: asuessenbach Date: Thu, 10 Feb 2022 09:49:24 +0100 Subject: [PATCH] Enclose "free" in parenthesis to prevent interference with MSVC's debug free --- VulkanHppGenerator.cpp | 21 ++++++++++++++++--- vulkan/vulkan.hpp | 4 ++-- vulkan/vulkan_funcs.hpp | 44 +++++++++++++++++++-------------------- vulkan/vulkan_handles.hpp | 44 +++++++++++++++++++-------------------- 4 files changed, 64 insertions(+), 49 deletions(-) diff --git a/VulkanHppGenerator.cpp b/VulkanHppGenerator.cpp index bc48f96..0a79880 100644 --- a/VulkanHppGenerator.cpp +++ b/VulkanHppGenerator.cpp @@ -3136,6 +3136,20 @@ std::string VulkanHppGenerator::generateCommandDefinitions( std::string const & destroyCommandString.replace( pos, commandName.length(), shortenedName ); pos = destroyCommandString.find( commandName, pos ); } + + // special handling for "free", to prevent interfering with MSVC debug free! + if ( shortenedName == "free" ) + { + std::string toEncloseString = stripPrefix( handle, "Vk" ) + "::free"; + std::string enclosedString = "( " + toEncloseString + " )"; + pos = destroyCommandString.find( toEncloseString ); + while ( pos != std::string::npos ) + { + destroyCommandString.replace( pos, toEncloseString.length(), enclosedString ); + pos = destroyCommandString.find( toEncloseString, pos + enclosedString.length() ); + } + } + // we need to remove the default argument for the first argument, to prevent ambiguities! assert( 1 < commandIt->second.params.size() ); pos = destroyCommandString.find( commandIt->second.params[1].name ); // skip the standard version of the function @@ -6031,7 +6045,8 @@ std::string VulkanHppGenerator::generateDestroyCommand( std::string const & name } else if ( name.substr( 2, 4 ) == "Free" ) { - shortenedName = "free"; + // enclose "free" in parenthesis to prevent interference with MSVC debug free + shortenedName = "( free )"; } else { @@ -16470,7 +16485,7 @@ int main( int argc, char ** argv ) void destroy( T t ) VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( m_owner && m_dispatch ); - m_owner.free( t, m_allocationCallbacks, *m_dispatch ); + ( m_owner.free )( t, m_allocationCallbacks, *m_dispatch ); } private: @@ -16570,7 +16585,7 @@ int main( int argc, char ** argv ) template void destroy(T t) VULKAN_HPP_NOEXCEPT { - m_owner.free( m_pool, t, *m_dispatch ); + ( m_owner.free )( m_pool, t, *m_dispatch ); } private: diff --git a/vulkan/vulkan.hpp b/vulkan/vulkan.hpp index 738a244..86eb346 100644 --- a/vulkan/vulkan.hpp +++ b/vulkan/vulkan.hpp @@ -5971,7 +5971,7 @@ namespace VULKAN_HPP_NAMESPACE void destroy( T t ) VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( m_owner && m_dispatch ); - m_owner.free( t, m_allocationCallbacks, *m_dispatch ); + ( m_owner.free )( t, m_allocationCallbacks, *m_dispatch ); } private: @@ -6037,7 +6037,7 @@ namespace VULKAN_HPP_NAMESPACE template void destroy( T t ) VULKAN_HPP_NOEXCEPT { - m_owner.free( m_pool, t, *m_dispatch ); + ( m_owner.free )( m_pool, t, *m_dispatch ); } private: diff --git a/vulkan/vulkan_funcs.hpp b/vulkan/vulkan_funcs.hpp index 5980f5d..a048f0a 100644 --- a/vulkan/vulkan_funcs.hpp +++ b/vulkan/vulkan_funcs.hpp @@ -964,9 +964,9 @@ namespace VULKAN_HPP_NAMESPACE #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template - VULKAN_HPP_INLINE void Device::free( VULKAN_HPP_NAMESPACE::DeviceMemory memory, - const VULKAN_HPP_NAMESPACE::AllocationCallbacks * pAllocator, - Dispatch const & d ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_INLINE void( Device::free )( VULKAN_HPP_NAMESPACE::DeviceMemory memory, + const VULKAN_HPP_NAMESPACE::AllocationCallbacks * pAllocator, + Dispatch const & d ) const VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); d.vkFreeMemory( @@ -975,9 +975,9 @@ namespace VULKAN_HPP_NAMESPACE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - VULKAN_HPP_INLINE void Device::free( VULKAN_HPP_NAMESPACE::DeviceMemory memory, - Optional allocator, - Dispatch const & d ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_INLINE void( Device::free )( VULKAN_HPP_NAMESPACE::DeviceMemory memory, + Optional allocator, + Dispatch const & d ) const VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); d.vkFreeMemory( m_device, @@ -3862,10 +3862,10 @@ namespace VULKAN_HPP_NAMESPACE #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template - VULKAN_HPP_INLINE Result Device::free( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, - uint32_t descriptorSetCount, - const VULKAN_HPP_NAMESPACE::DescriptorSet * pDescriptorSets, - Dispatch const & d ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_INLINE Result( Device::free )( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, + uint32_t descriptorSetCount, + const VULKAN_HPP_NAMESPACE::DescriptorSet * pDescriptorSets, + Dispatch const & d ) const VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); return static_cast( @@ -3877,10 +3877,10 @@ namespace VULKAN_HPP_NAMESPACE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - VULKAN_HPP_INLINE typename ResultValueType::type - Device::free( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, - ArrayProxy const & descriptorSets, - Dispatch const & d ) const + VULKAN_HPP_INLINE typename ResultValueType::type( Device::free )( + VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, + ArrayProxy const & descriptorSets, + Dispatch const & d ) const { VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); Result result = static_cast( @@ -3888,7 +3888,7 @@ namespace VULKAN_HPP_NAMESPACE static_cast( descriptorPool ), descriptorSets.size(), reinterpret_cast( descriptorSets.data() ) ) ); - return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::Device::free" ); + return createResultValue( result, VULKAN_HPP_NAMESPACE_STRING "::( Device::free )" ); } #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ @@ -4433,10 +4433,10 @@ namespace VULKAN_HPP_NAMESPACE #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template - VULKAN_HPP_INLINE void Device::free( VULKAN_HPP_NAMESPACE::CommandPool commandPool, - uint32_t commandBufferCount, - const VULKAN_HPP_NAMESPACE::CommandBuffer * pCommandBuffers, - Dispatch const & d ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_INLINE void( Device::free )( VULKAN_HPP_NAMESPACE::CommandPool commandPool, + uint32_t commandBufferCount, + const VULKAN_HPP_NAMESPACE::CommandBuffer * pCommandBuffers, + Dispatch const & d ) const VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); d.vkFreeCommandBuffers( m_device, @@ -4447,9 +4447,9 @@ namespace VULKAN_HPP_NAMESPACE #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - VULKAN_HPP_INLINE void Device::free( VULKAN_HPP_NAMESPACE::CommandPool commandPool, - ArrayProxy const & commandBuffers, - Dispatch const & d ) const VULKAN_HPP_NOEXCEPT + VULKAN_HPP_INLINE void( Device::free )( VULKAN_HPP_NAMESPACE::CommandPool commandPool, + ArrayProxy const & commandBuffers, + Dispatch const & d ) const VULKAN_HPP_NOEXCEPT { VULKAN_HPP_ASSERT( d.getVkHeaderVersion() == VK_HEADER_VERSION ); d.vkFreeCommandBuffers( m_device, diff --git a/vulkan/vulkan_handles.hpp b/vulkan/vulkan_handles.hpp index fdaf6a1..00d8887 100644 --- a/vulkan/vulkan_handles.hpp +++ b/vulkan/vulkan_handles.hpp @@ -7791,15 +7791,15 @@ namespace VULKAN_HPP_NAMESPACE #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template - void free( VULKAN_HPP_NAMESPACE::DeviceMemory memory, - const VULKAN_HPP_NAMESPACE::AllocationCallbacks * pAllocator, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; + void( free )( VULKAN_HPP_NAMESPACE::DeviceMemory memory, + const VULKAN_HPP_NAMESPACE::AllocationCallbacks * pAllocator, + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - void free( VULKAN_HPP_NAMESPACE::DeviceMemory memory, - Optional allocator - VULKAN_HPP_DEFAULT_ARGUMENT_NULLPTR_ASSIGNMENT, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; + void( free )( VULKAN_HPP_NAMESPACE::DeviceMemory memory, + Optional allocator + VULKAN_HPP_DEFAULT_ARGUMENT_NULLPTR_ASSIGNMENT, + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -8993,16 +8993,16 @@ namespace VULKAN_HPP_NAMESPACE #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template - Result free( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, - uint32_t descriptorSetCount, - const VULKAN_HPP_NAMESPACE::DescriptorSet * pDescriptorSets, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; + Result( free )( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, + uint32_t descriptorSetCount, + const VULKAN_HPP_NAMESPACE::DescriptorSet * pDescriptorSets, + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - typename ResultValueType::type - free( VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, - ArrayProxy const & descriptorSets, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; + typename ResultValueType::type( free )( + VULKAN_HPP_NAMESPACE::DescriptorPool descriptorPool, + ArrayProxy const & descriptorSets, + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template @@ -9243,15 +9243,15 @@ namespace VULKAN_HPP_NAMESPACE #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ template - void free( VULKAN_HPP_NAMESPACE::CommandPool commandPool, - uint32_t commandBufferCount, - const VULKAN_HPP_NAMESPACE::CommandBuffer * pCommandBuffers, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; + void( free )( VULKAN_HPP_NAMESPACE::CommandPool commandPool, + uint32_t commandBufferCount, + const VULKAN_HPP_NAMESPACE::CommandBuffer * pCommandBuffers, + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; #ifndef VULKAN_HPP_DISABLE_ENHANCED_MODE template - void free( VULKAN_HPP_NAMESPACE::CommandPool commandPool, - ArrayProxy const & commandBuffers, - Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; + void( free )( VULKAN_HPP_NAMESPACE::CommandPool commandPool, + ArrayProxy const & commandBuffers, + Dispatch const & d VULKAN_HPP_DEFAULT_DISPATCHER_ASSIGNMENT ) const VULKAN_HPP_NOEXCEPT; #endif /*VULKAN_HPP_DISABLE_ENHANCED_MODE*/ //=== VK_VERSION_1_1 ===