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.
|
// MSVC 2013 ignores that move constructors cannot throw in std::vector, so just don't define it.
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||||
#define SPIRV_CROSS_NOEXCEPT
|
#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
|
#else
|
||||||
#define SPIRV_CROSS_NOEXCEPT noexcept
|
#define SPIRV_CROSS_NOEXCEPT noexcept
|
||||||
#define SPIRV_CROSS_ALIGNAS(N) alignas(N)
|
|
||||||
#define SPIRV_CROSS_CLASS_ALIGN(N)
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if __cplusplus >= 201402l
|
#if __cplusplus >= 201402l
|
||||||
@ -112,16 +106,32 @@ public:
|
|||||||
|
|
||||||
// std::aligned_storage does not support size == 0, so roll our own.
|
// std::aligned_storage does not support size == 0, so roll our own.
|
||||||
template <typename T, size_t N>
|
template <typename T, size_t N>
|
||||||
SPIRV_CROSS_CLASS_ALIGN(8) class AlignedBuffer
|
class AlignedBuffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
T *data()
|
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);
|
return reinterpret_cast<T *>(aligned_char);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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>
|
template <typename T>
|
||||||
|
Loading…
Reference in New Issue
Block a user