From dc243c2e828a8159eba3d60a063fa98e12897263 Mon Sep 17 00:00:00 2001 From: heavenstone Date: Thu, 20 Jul 2023 17:40:25 +0900 Subject: [PATCH] Defined PSD_STATIC_ASSERT macros message can be omitted under C++17 Fix Sample code. --- src/Psd/PsdCompilerMacros.h | 8 ++++++++ src/Samples/PsdSamples.cpp | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Psd/PsdCompilerMacros.h b/src/Psd/PsdCompilerMacros.h index ad39e69..952cb56 100644 --- a/src/Psd/PsdCompilerMacros.h +++ b/src/Psd/PsdCompilerMacros.h @@ -144,3 +144,11 @@ #define static_assert(condition, message) typedef char PSD_JOIN(static_assert_impl_, __LINE__)[(condition) ? 1 : -1] #define nullptr NULL #endif + +#define PSD_STATIC_ASSERT_MSG(condition, message) static_assert((condition), message) + +#if __cpp_static_assert >= 201411 + #define PSD_STATIC_ASSERT(condition) static_assert((condition)) +#else + #define PSD_STATIC_ASSERT(condition) static_assert((condition), "") +#endif diff --git a/src/Samples/PsdSamples.cpp b/src/Samples/PsdSamples.cpp index 6089603..32e79eb 100644 --- a/src/Samples/PsdSamples.cpp +++ b/src/Samples/PsdSamples.cpp @@ -366,7 +366,7 @@ int SampleReadPsd(void) { #ifdef _WIN32 //In Windows wchar_t is utf16 - static_assert(sizeof(wchar_t) == sizeof(uint16_t)); + PSD_STATIC_ASSERT(sizeof(wchar_t) == sizeof(uint16_t)); layerName << reinterpret_cast(layer->utf16Name); #else //In Linux, wchar_t is utf32 @@ -387,7 +387,7 @@ int SampleReadPsd(void) { return ((high << 10) + low - 0x35fdc00); }; - static_assert(sizeof(wchar_t) == sizeof(uint32_t)); + PSD_STATIC_ASSERT(sizeof(wchar_t) == sizeof(uint32_t)); //Begin convert size_t u16len = 0;