From d3e7edc50f2b1a4ab9174ada15948dd1f2b27b87 Mon Sep 17 00:00:00 2001 From: Eugene Golushkov Date: Sat, 21 Sep 2024 01:23:56 +0200 Subject: [PATCH] use OGRE_STATIC_ASSERT for single argument checks --- OgreMain/include/OgreAssert.h | 8 +++----- RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/OgreMain/include/OgreAssert.h b/OgreMain/include/OgreAssert.h index 2aede1c8cb4..d88c8b63072 100644 --- a/OgreMain/include/OgreAssert.h +++ b/OgreMain/include/OgreAssert.h @@ -126,12 +126,10 @@ namespace Ogre # define OGRE_VERIFY_MSG( cond, msg, ... ) ( (void)0 ) #endif -#if __cplusplus >= 201103L +#if __cplusplus >= 201703L || defined( _MSVC_LANG ) && _MSVC_LANG >= 201703L +# define OGRE_STATIC_ASSERT( x ) static_assert( x ) +#else // C++11 # define OGRE_STATIC_ASSERT( x ) static_assert( x, # x ) -#else -# define OGRE_STATIC_ASSERT( x ) \ - typedef char OgreStaticAssert[( x ) ? 1 : -1]; \ - OGRE_UNUSED( OgreStaticAssert ); #endif #endif diff --git a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp index 9e0f038a1e8..e0580907d3f 100644 --- a/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp +++ b/RenderSystems/Vulkan/src/OgreVulkanRenderSystem.cpp @@ -528,7 +528,7 @@ namespace Ogre //------------------------------------------------------------------------- void VulkanRenderSystem::savePipelineCache( DataStreamPtr stream ) const { - static_assert( sizeof( PipelineCachePrefixHeader ) == 48 ); + OGRE_STATIC_ASSERT( sizeof( PipelineCachePrefixHeader ) == 48 ); if( mActiveDevice->mPipelineCache ) { size_t size{}; @@ -559,7 +559,7 @@ namespace Ogre hdr.driverVersion = mActiveDevice->mDeviceProperties.driverVersion; hdr.driverABI = sizeof( void * ); memcpy( hdr.uuid, mActiveDevice->mDeviceProperties.pipelineCacheUUID, VK_UUID_SIZE ); - static_assert( VK_UUID_SIZE == 16 ); + OGRE_STATIC_ASSERT( VK_UUID_SIZE == 16 ); uint64 hashResult[2] = {}; OGRE_HASH128_FUNC( buf.data(), (int)buf.size(), IdString::Seed, hashResult );