Skip to content

Commit

Permalink
Defined PSD_STATIC_ASSERT macros
Browse files Browse the repository at this point in the history
  message can be omitted under C++17

Fix Sample code.
  • Loading branch information
heavenstone committed Jul 20, 2023
1 parent 8885b8e commit dc243c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Psd/PsdCompilerMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/Samples/PsdSamples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<wchar_t*>(layer->utf16Name);
#else
//In Linux, wchar_t is utf32
Expand All @@ -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;
Expand Down

0 comments on commit dc243c2

Please sign in to comment.