mirror of
https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git
synced 2025-07-14 02:27:40 -04:00
Replace COMPILER_ASSERT with C++0B static_assert
This commit is contained in:
@ -208,7 +208,7 @@ static void LogV (ELogSev sev, const wchar_t fmt[], va_list args) {
|
||||
{ stdout, L"Inf" },
|
||||
{ stderr, L"Err" },
|
||||
};
|
||||
COMPILER_ASSERT(arrsize(s_log) == kNumLogSev);
|
||||
static_assert(arrsize(s_log) == kNumLogSev, "Log severity array and enum have different sizes");
|
||||
|
||||
fwprintf (s_log[sev].file, L"%s: ", s_log[sev].pre);
|
||||
vfwprintf(s_log[sev].file, fmt, args);
|
||||
|
@ -297,14 +297,6 @@ typedef hsColor32 hsRGBAColor32;
|
||||
# define NULL_STMT ((void)0)
|
||||
#endif
|
||||
|
||||
|
||||
//===========================================================================
|
||||
// Old COMPILER_ASSERT Macro
|
||||
// This DEPRECATED. Use static_assert instead!
|
||||
//===========================================================================
|
||||
#define COMPILER_ASSERT(expr) static_assert(expr, "old compiler assert failure")
|
||||
#define COMPILER_ASSERT_HEADER(prefix,expr) static_assert(expr, "old compiler assert failure")
|
||||
|
||||
//===========================================================================
|
||||
template<class T>
|
||||
inline T max (const T & a, const T & b) {
|
||||
|
@ -171,7 +171,7 @@ enum EConnType {
|
||||
|
||||
kNumConnTypes
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(EConnType, kNumConnTypes < 256);
|
||||
static_assert(kNumConnTypes <= 0xFF, "EConnType overflows uint8");
|
||||
|
||||
#define IS_TEXT_CONNTYPE(c) \
|
||||
(((int)(c)) == kConnTypeAdminInterface)
|
||||
|
@ -583,7 +583,7 @@ void CSocket::OnWriteReady () {
|
||||
&m_sendQueue[result],
|
||||
m_sendQueue.Bytes() - result
|
||||
);
|
||||
COMPILER_ASSERT(sizeof(m_sendQueue[0]) == sizeof(uint8_t));
|
||||
static_assert(sizeof(m_sendQueue[0]) == sizeof(uint8_t), "SendQueue array members are an unexpected size");
|
||||
m_sendQueue.SetCount(m_sendQueue.Count() - result);
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ void AsyncSleep (unsigned sleepMs) {
|
||||
|
||||
//============================================================================
|
||||
long AsyncPerfGetCounter (unsigned id) {
|
||||
COMPILER_ASSERT(arrsize(s_perf) == kNumAsyncPerfCounters);
|
||||
static_assert(arrsize(s_perf) == kNumAsyncPerfCounters, "Max async counters and array size do not match.");
|
||||
ASSERT(id < kNumAsyncPerfCounters);
|
||||
return s_perf[id];
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ const wchar_t * NetErrorToString (ENetError code) {
|
||||
L"Server Busy", // kNetErrServerBusy
|
||||
L"Vault Node Access Violation", // kNetErrVaultNodeAccessViolation
|
||||
};
|
||||
COMPILER_ASSERT(arrsize(s_errors) == kNumNetErrors);
|
||||
static_assert(arrsize(s_errors) == kNumNetErrors, "Number of Net Error descriptions and total Net Error count are not equal");
|
||||
|
||||
if ((unsigned)code >= arrsize(s_errors)) {
|
||||
if (code == kNetPending)
|
||||
@ -172,7 +172,7 @@ const wchar_t * NetErrorAsString (ENetError code) {
|
||||
L"kNetErrServerBusy",
|
||||
L"kNetErrVaultNodeAccessViolation",
|
||||
};
|
||||
COMPILER_ASSERT(arrsize(s_errors) == kNumNetErrors);
|
||||
static_assert(arrsize(s_errors) == kNumNetErrors, "Number of string-ized Net Errors and total Net Error count are not equal");
|
||||
|
||||
if ((unsigned)code >= arrsize(s_errors)) {
|
||||
if (code == kNetPending)
|
||||
|
@ -78,7 +78,7 @@ namespace pnNetCli {
|
||||
|
||||
***/
|
||||
|
||||
COMPILER_ASSERT(IS_POW2(kNetDiffieHellmanKeyBits));
|
||||
static_assert(IS_POW2(kNetDiffieHellmanKeyBits), "DH Key bit count is not a power of 2");
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -133,7 +133,7 @@ enum {
|
||||
|
||||
kNumCli2AuthMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2Auth, kNumCli2AuthMessages <= (uint16_t)-1);
|
||||
static_assert(kNumCli2AuthMessages <= 0xFFFF, "Cli2Auth message types overflow uint16");
|
||||
|
||||
enum {
|
||||
// Global
|
||||
@ -212,7 +212,7 @@ enum {
|
||||
|
||||
kNumAuth2CliMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2Auth, kNumAuth2CliMessages <= (uint16_t)-1);
|
||||
static_assert(kNumAuth2CliMessages <= 0xFFFF, "Auth2Cli message types overflow uint16");
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
@ -65,7 +65,7 @@ enum {
|
||||
|
||||
kNumCli2GameMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2Game, kNumCli2GameMessages <= (uint16_t)-1);
|
||||
static_assert(kNumCli2GameMessages <= 0xFFFF, "Cli2Game message types overflow uint16");
|
||||
|
||||
enum {
|
||||
// Global
|
||||
@ -80,7 +80,7 @@ enum {
|
||||
|
||||
kNumGame2CliMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2Game, kNumGame2CliMessages <= (uint16_t)-1);
|
||||
static_assert(kNumGame2CliMessages <= 0xFFFF, "Game2Cli message types overflow uint16");
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
@ -62,7 +62,7 @@ enum {
|
||||
|
||||
kNumCli2GateKeeperMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2GateKeeper, kNumCli2GateKeeperMessages <= (uint16_t)-1);
|
||||
static_assert(kNumCli2GateKeeperMessages <= 0xFFFF, "Cli2GateKeeper message types overflow uint16");
|
||||
|
||||
enum {
|
||||
// Global
|
||||
@ -72,7 +72,7 @@ enum {
|
||||
|
||||
kNumGateKeeper2CliMessages
|
||||
};
|
||||
COMPILER_ASSERT_HEADER(Cli2GateKeeper, kNumGateKeeper2CliMessages <= (uint16_t)-1);
|
||||
static_assert(kNumGateKeeper2CliMessages <= 0xFFFF, "GateKeeper2Cli message types overflow uint16");
|
||||
|
||||
|
||||
//============================================================================
|
||||
|
@ -53,7 +53,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
namespace pnNpCommon {
|
||||
|
||||
// Verify our uint64_t constants were properly inited as such.
|
||||
COMPILER_ASSERT(NetVaultNode::kBlob_2);
|
||||
static_assert(NetVaultNode::kBlob_2, "NetVaultNode constants failed to init");
|
||||
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
// This value is manually changed upon each branch so that client applications
|
||||
// built from this branch may not connect to servers built from another.
|
||||
#define BRANCH_ID 1
|
||||
COMPILER_ASSERT(BRANCH_ID != 0);
|
||||
static_assert(BRANCH_ID != 0, "BranchID cannot be 0");
|
||||
|
||||
#else
|
||||
|
||||
|
@ -58,7 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
// This line must NEVER be modified manually; it is automatically updated
|
||||
// by the build server.
|
||||
#define BUILD_ID 912
|
||||
COMPILER_ASSERT(BUILD_ID != 0);
|
||||
static_assert(BUILD_ID != 0, "BuildID cannot be 0");
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -56,7 +56,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
***/
|
||||
|
||||
// make sure our definition is at least as big as the compiler's definition
|
||||
COMPILER_ASSERT(MAX_PATH >= _MAX_PATH);
|
||||
static_assert(MAX_PATH >= _MAX_PATH, "Windows and STDlib MAX_PATH constants differ");
|
||||
|
||||
|
||||
//===========================================================================
|
||||
@ -546,7 +546,7 @@ EPathCreateDirError PathCreateDirectory (const wchar_t path[], unsigned flags) {
|
||||
// if we successfully created the directory then we're done
|
||||
if (result) {
|
||||
// Avoid check for kPathCreateDirFlagOsError
|
||||
COMPILER_ASSERT(kPathCreateDirSuccess == NO_ERROR);
|
||||
static_assert(kPathCreateDirSuccess == NO_ERROR, "Path creation success and NO_ERROR constants differ");
|
||||
return kPathCreateDirSuccess;
|
||||
}
|
||||
|
||||
|
@ -51,8 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
|
||||
|
||||
#if 0
|
||||
|
||||
COMPILER_ASSERT(sizeof(Uuid) >= sizeof(GUID));
|
||||
|
||||
void Uuid::Clear()
|
||||
{
|
||||
UuidCreateNil( (GUID *)this );
|
||||
@ -120,7 +118,7 @@ Uuid Uuid::Generate()
|
||||
*
|
||||
***/
|
||||
|
||||
COMPILER_ASSERT(sizeof(Uuid) >= sizeof(GUID));
|
||||
static_assert(sizeof(Uuid) >= sizeof(GUID), "pnUtils Uuid and Win32 GUID types differ in size");
|
||||
|
||||
//============================================================================
|
||||
Uuid GuidGenerate () {
|
||||
@ -137,7 +135,7 @@ void GuidClear (Uuid * uuid) {
|
||||
//============================================================================
|
||||
bool GuidFromString (const wchar_t str[], Uuid * uuid) {
|
||||
ASSERT(uuid);
|
||||
COMPILER_ASSERT(sizeof(wchar_t) == sizeof(unsigned short));
|
||||
static_assert(sizeof(wchar_t) == sizeof(unsigned short), "Wchar is not an uint16");
|
||||
return RPC_S_OK == UuidFromStringW((unsigned short *) str, (GUID *) uuid);
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ uint32_t TimeGetSecondsSince2001Utc () {
|
||||
uint64_t TimeGetTime () {
|
||||
#ifdef HS_BUILD_FOR_WIN32
|
||||
uint64_t time;
|
||||
COMPILER_ASSERT(sizeof(uint64_t) == sizeof(FILETIME));
|
||||
static_assert(sizeof(uint64_t) == sizeof(FILETIME), "FILETIME is not a uint64");
|
||||
GetSystemTimeAsFileTime((FILETIME *) &time);
|
||||
return time;
|
||||
#else
|
||||
|
@ -271,7 +271,7 @@ static const char * s_transTypes[] = {
|
||||
"GkAuthSrvIpAddress",
|
||||
|
||||
};
|
||||
COMPILER_ASSERT(arrsize(s_transTypes) == kNumTransTypes);
|
||||
static_assert(arrsize(s_transTypes) == kNumTransTypes, "Ngl Trans array and enum differ in size");
|
||||
|
||||
static long s_perfTransCount[kNumTransTypes];
|
||||
|
||||
|
@ -4017,7 +4017,7 @@ bool VaultFindNodeTrans::Recv (
|
||||
const Auth2Cli_VaultNodeFindReply & reply = *(const Auth2Cli_VaultNodeFindReply *) msg;
|
||||
|
||||
if (IS_NET_SUCCESS(reply.result)) {
|
||||
COMPILER_ASSERT(sizeof(unsigned) == sizeof(uint32_t));
|
||||
static_assert(sizeof(unsigned) == sizeof(uint32_t), "unsigned is not the same size as uint32_t");
|
||||
m_nodeIds.Set((unsigned *)reply.nodeIds, reply.nodeIdCount);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user