Merge pull request #609 from asuessenbach/windows

Add some workarounds to not include windows.h on _WIN32 platform.
This commit is contained in:
Andreas Süßenbach 2020-05-14 11:58:58 +02:00 committed by GitHub
commit ae3460a715
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 50 additions and 36 deletions

View File

@ -1404,6 +1404,15 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
{
str += R"(
#if VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL
# if defined( _WIN32 )
namespace detail
{
extern "C" __declspec( dllimport ) void * __stdcall LoadLibraryA( char const * lpLibFileName );
extern "C" __declspec( dllimport ) int __stdcall FreeLibrary( void * hLibModule );
extern "C" __declspec( dllimport ) void * __stdcall GetProcAddress( void * hModule, char const * lpProcName );
} // namespace detail
# endif
class DynamicLoader
{
public:
@ -1418,9 +1427,9 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
# if defined( __linux__ ) || defined( __APPLE__ )
m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL );
# elif defined( _WIN32 )
m_library = LoadLibrary( vulkanLibraryName.c_str() );
m_library = detail::LoadLibraryA( vulkanLibraryName.c_str() );
# else
VULKAN_HPP_ASSERT( false && "unsupported platform" );
# error unsupported platform
# endif
}
else
@ -1434,9 +1443,9 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
# elif defined( __APPLE__ )
m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL );
# elif defined( _WIN32 )
m_library = LoadLibrary( TEXT( "vulkan-1.dll" ) );
m_library = detail::LoadLibraryA( "vulkan-1.dll" );
# else
VULKAN_HPP_ASSERT( false && "unsupported platform" );
# error unsupported platform
# endif
}
@ -1475,7 +1484,9 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
# if defined( __linux__ ) || defined( __APPLE__ )
dlclose( m_library );
# elif defined( _WIN32 )
FreeLibrary( m_library );
detail::FreeLibrary( m_library );
# else
# error unsupported platform
# endif
}
}
@ -1486,7 +1497,9 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
# if defined( __linux__ ) || defined( __APPLE__ )
return (T)dlsym( m_library, function );
# elif defined( _WIN32 )
return (T)GetProcAddress( m_library, function );
return (T)detail::GetProcAddress( m_library, function );
# else
# error unsupported platform
# endif
}
@ -1494,10 +1507,8 @@ void VulkanHppGenerator::appendDispatchLoaderDynamic( std::string & str )
private:
bool m_success;
#if defined(__linux__) || defined(__APPLE__)
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( _WIN32 )
void * m_library;
#elif defined(_WIN32)
HMODULE m_library;
# else
# error unsupported platform
# endif
@ -7811,10 +7822,6 @@ int main( int argc, char ** argv )
# if defined(__linux__) || defined(__APPLE__)
# include <dlfcn.h>
# endif
# if defined(_WIN32)
# include <windows.h>
# endif
#endif
#if 201711 <= __cpp_impl_three_way_comparison

View File

@ -69,10 +69,6 @@
# if defined( __linux__ ) || defined( __APPLE__ )
# include <dlfcn.h>
# endif
# if defined( _WIN32 )
# include <windows.h>
# endif
#endif
#if 201711 <= __cpp_impl_three_way_comparison
@ -96704,6 +96700,15 @@ namespace VULKAN_HPP_NAMESPACE
};
#if VULKAN_HPP_ENABLE_DYNAMIC_LOADER_TOOL
# if defined( _WIN32 )
namespace detail
{
extern "C" __declspec( dllimport ) void * __stdcall LoadLibraryA( char const * lpLibFileName );
extern "C" __declspec( dllimport ) int __stdcall FreeLibrary( void * hLibModule );
extern "C" __declspec( dllimport ) void * __stdcall GetProcAddress( void * hModule, char const * lpProcName );
} // namespace detail
# endif
class DynamicLoader
{
public:
@ -96718,9 +96723,9 @@ namespace VULKAN_HPP_NAMESPACE
# if defined( __linux__ ) || defined( __APPLE__ )
m_library = dlopen( vulkanLibraryName.c_str(), RTLD_NOW | RTLD_LOCAL );
# elif defined( _WIN32 )
m_library = LoadLibrary( vulkanLibraryName.c_str() );
m_library = detail::LoadLibraryA( vulkanLibraryName.c_str() );
# else
VULKAN_HPP_ASSERT( false && "unsupported platform" );
# error unsupported platform
# endif
}
else
@ -96734,9 +96739,9 @@ namespace VULKAN_HPP_NAMESPACE
# elif defined( __APPLE__ )
m_library = dlopen( "libvulkan.dylib", RTLD_NOW | RTLD_LOCAL );
# elif defined( _WIN32 )
m_library = LoadLibrary( TEXT( "vulkan-1.dll" ) );
m_library = detail::LoadLibraryA( "vulkan-1.dll" );
# else
VULKAN_HPP_ASSERT( false && "unsupported platform" );
# error unsupported platform
# endif
}
@ -96776,7 +96781,9 @@ namespace VULKAN_HPP_NAMESPACE
# if defined( __linux__ ) || defined( __APPLE__ )
dlclose( m_library );
# elif defined( _WIN32 )
FreeLibrary( m_library );
detail::FreeLibrary( m_library );
# else
# error unsupported platform
# endif
}
}
@ -96787,7 +96794,9 @@ namespace VULKAN_HPP_NAMESPACE
# if defined( __linux__ ) || defined( __APPLE__ )
return (T)dlsym( m_library, function );
# elif defined( _WIN32 )
return (T)GetProcAddress( m_library, function );
return (T)detail::GetProcAddress( m_library, function );
# else
# error unsupported platform
# endif
}
@ -96798,10 +96807,8 @@ namespace VULKAN_HPP_NAMESPACE
private:
bool m_success;
# if defined( __linux__ ) || defined( __APPLE__ )
# if defined( __linux__ ) || defined( __APPLE__ ) || defined( _WIN32 )
void * m_library;
# elif defined( _WIN32 )
HMODULE m_library;
# else
# error unsupported platform
# endif