Fixed VS warnings. Issue #238

This commit is contained in:
Бранимир Караџић
2020-04-29 17:57:22 -07:00
parent 7f6743a2db
commit 1d1d09a152
3 changed files with 10 additions and 6 deletions

View File

@@ -20,10 +20,14 @@
#define BX_COUNTOF(_x) sizeof(bx::CountOfRequireArrayArgumentT(_x) )
///
#define BX_IGNORE_C4127(_x) bx::ignoreC4127(!!(_x) )
#if BX_COMPILER_MSVC
# define BX_IGNORE_C4127(_x) bx::ignoreC4127(!!(_x) )
#else
# define BX_IGNORE_C4127(_x) (!!(_x) )
#endif // BX_COMPILER_MSVC
///
#define BX_ENABLED(_x) (bx::isEnabled<!!(_x)>::value)
#define BX_ENABLED(_x) BX_IGNORE_C4127(bx::isEnabled<!!(_x)>::value)
namespace bx
{

View File

@@ -27,7 +27,7 @@ namespace bx
union { void* ptr; uintptr_t addr; } un;
un.ptr = _ptr;
uintptr_t unaligned = un.addr + _extra; // space for header
uintptr_t aligned = bx::alignUp(unaligned, _align);
uintptr_t aligned = bx::alignUp(unaligned, int32_t(_align) );
un.addr = aligned;
return un.ptr;
}

View File

@@ -690,7 +690,7 @@ namespace bx
template <typename Ty>
inline bool isAligned(Ty _a, int32_t _align)
{
const Ty mask = _align - 1;
const Ty mask = Ty(_align - 1);
return 0 == (_a & mask);
}
@@ -710,7 +710,7 @@ namespace bx
template <typename Ty>
inline Ty alignDown(Ty _a, int32_t _align)
{
const Ty mask = _align - 1;
const Ty mask = Ty(_align - 1);
return Ty(_a & ~mask);
}
@@ -733,7 +733,7 @@ namespace bx
template <typename Ty>
inline Ty alignUp(Ty _a, int32_t _align)
{
const Ty mask = _align - 1;
const Ty mask = Ty(_align - 1);
return Ty( (_a + mask) & ~mask);
}