mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Make code compatible with older C++ versions
Made compatible with earlier C++ versions without having verbose compiler warnings.
This commit is contained in:
parent
d8cc85da6b
commit
a1f7cc9a0d
@ -33,6 +33,15 @@
|
||||
#else
|
||||
#error "unknown compiler"
|
||||
#endif
|
||||
|
||||
//C++17 specifics
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
#define SDK_HAS_CPP17 1
|
||||
#define HEXRAYS_CONSTEXPR constexpr
|
||||
#else
|
||||
#define HEXRAYS_CONSTEXPR
|
||||
#endif
|
||||
|
||||
typedef unsigned int uint;
|
||||
typedef unsigned char uchar;
|
||||
typedef unsigned short ushort;
|
||||
@ -241,7 +250,7 @@ template<class T> T __ROL__(T value, int count)
|
||||
{
|
||||
count %= nbits;
|
||||
T high = value >> (nbits - count);
|
||||
if constexpr ( T(-1) < 0 ) // signed value
|
||||
if HEXRAYS_CONSTEXPR( T(-1) < 0 ) // signed value
|
||||
high &= ~((T(-1) << count));
|
||||
value <<= count;
|
||||
value |= high;
|
||||
|
@ -5,6 +5,14 @@
|
||||
#pragma intrinsic(__rdtsc)
|
||||
#endif
|
||||
|
||||
#if ((defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) || __cplusplus >= 201703L)
|
||||
//C++17 specific
|
||||
#define SDK_HAS_CPP17 1
|
||||
#define V_CONSTEXPR constexpr
|
||||
#else
|
||||
#define V_CONSTEXPR
|
||||
#endif
|
||||
|
||||
#define TIER0_DLL_EXPORT
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -136,7 +136,7 @@ public:
|
||||
|
||||
bool AssignIf(T conditionValue, T newValue)
|
||||
{
|
||||
if constexpr(sizeof(T) == sizeof(int32))
|
||||
if V_CONSTEXPR(sizeof(T) == sizeof(int32))
|
||||
return ThreadInterlockedAssignIf((LONG*)&m_value, (int32)newValue, (int32)conditionValue);
|
||||
else
|
||||
return ThreadInterlockedAssignIf64((int64*)&m_value, (int64)newValue, (int64)conditionValue);
|
||||
|
@ -592,7 +592,7 @@ bool V_IsAbsolutePath(const char* pStr)
|
||||
bool bIsAbsolute = (pStr[0] && pStr[1] == ':') || pStr[0] == '/' || pStr[0] == '\\';
|
||||
#endif
|
||||
|
||||
if constexpr (IsX360() && !bIsAbsolute)
|
||||
if V_CONSTEXPR(IsX360() && !bIsAbsolute)
|
||||
{
|
||||
bIsAbsolute = (V_stristr(pStr, ":") != NULL);
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ public:
|
||||
|
||||
FORCEINLINE void ActivateByteSwappingIfBigEndian(void)
|
||||
{
|
||||
if constexpr ((IsX360() || IsPS3()))
|
||||
if V_CONSTEXPR((IsX360() || IsPS3()))
|
||||
ActivateByteSwapping(true);
|
||||
}
|
||||
|
||||
@ -714,7 +714,7 @@ inline void CUtlBuffer::GetTypeBin< float >(float& dest)
|
||||
if (CheckGet(sizeof(float)))
|
||||
{
|
||||
uintptr_t pData = (uintptr_t)PeekGet();
|
||||
if constexpr ((IsX360() || IsPS3()) && (pData & 0x03))
|
||||
if V_CONSTEXPR((IsX360() || IsPS3()) && (pData & 0x03))
|
||||
{
|
||||
// handle unaligned read
|
||||
((unsigned char*)&dest)[0] = ((unsigned char*)pData)[0];
|
||||
@ -745,7 +745,7 @@ inline void CUtlBuffer::GetTypeBin< double >(double& dest)
|
||||
if (CheckGet(sizeof(double)))
|
||||
{
|
||||
uintptr_t pData = (uintptr_t)PeekGet();
|
||||
if constexpr ((IsX360() || IsPS3()) && (pData & 0x07))
|
||||
if V_CONSTEXPR((IsX360() || IsPS3()) && (pData & 0x07))
|
||||
{
|
||||
// handle unaligned read
|
||||
((unsigned char*)&dest)[0] = ((unsigned char*)pData)[0];
|
||||
|
@ -44,7 +44,7 @@ void GenerateQuadIndexBuffer(unsigned short* pIndices, int nIndexCount, int nFir
|
||||
for (i = 0; i < numQuads; ++i)
|
||||
{
|
||||
// Have to deal with endian-ness
|
||||
if constexpr (IsX360() || IsPS3())
|
||||
if V_CONSTEXPR(IsX360() || IsPS3())
|
||||
{
|
||||
// this avoids compiler write reodering and prevents the write-combined out-of-order penalty
|
||||
// _WriteBarrier won't compile here, and volatile is ignored
|
||||
|
Loading…
x
Reference in New Issue
Block a user