Try another MSVC 2013 workaround.
This commit is contained in:
parent
3a57286595
commit
5b603e0166
@ -90,14 +90,8 @@ public:
|
||||
// MSVC 2013 ignores that move constructors cannot throw in std::vector, so just don't define it.
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
#define SPIRV_CROSS_NOEXCEPT
|
||||
|
||||
// Alignas is broken in MSVC 2013, work around it with compiler specifics.
|
||||
#define SPIRV_CROSS_ALIGNAS(N)
|
||||
#define SPIRV_CROSS_CLASS_ALIGN(N) __declspec(align(N))
|
||||
#else
|
||||
#define SPIRV_CROSS_NOEXCEPT noexcept
|
||||
#define SPIRV_CROSS_ALIGNAS(N) alignas(N)
|
||||
#define SPIRV_CROSS_CLASS_ALIGN(N)
|
||||
#endif
|
||||
|
||||
#if __cplusplus >= 201402l
|
||||
@ -112,16 +106,32 @@ public:
|
||||
|
||||
// std::aligned_storage does not support size == 0, so roll our own.
|
||||
template <typename T, size_t N>
|
||||
SPIRV_CROSS_CLASS_ALIGN(8) class AlignedBuffer
|
||||
class AlignedBuffer
|
||||
{
|
||||
public:
|
||||
T *data()
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// MSVC 2013 workarounds, sigh ...
|
||||
// Only use this workaround on MSVC 2013 due to some confusion around default initialized unions.
|
||||
// Spec seems to suggest the memory will be zero-initialized, which is *not* what we want.
|
||||
return reinterpret_cast<T *>(u.aligned_char);
|
||||
#else
|
||||
return reinterpret_cast<T *>(aligned_char);
|
||||
#endif
|
||||
}
|
||||
|
||||
private:
|
||||
SPIRV_CROSS_ALIGNAS(T) char aligned_char[sizeof(T) * N];
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
// MSVC 2013 workarounds, sigh ...
|
||||
union
|
||||
{
|
||||
char aligned_char[sizeof(T) * N];
|
||||
double dummy_aligner;
|
||||
} u;
|
||||
#else
|
||||
alignas(T) char aligned_char[sizeof(T) * N];
|
||||
#endif
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user