1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-18 11:19:10 +00:00

Replace COMPILER_ASSERT with C++0B static_assert

This commit is contained in:
2012-06-17 03:10:59 -04:00
parent 5d30f69957
commit 3667fb62e2
18 changed files with 23 additions and 33 deletions

View File

@ -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)

View File

@ -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);
}

View File

@ -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];
}

View File

@ -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)

View File

@ -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");
/*****************************************************************************

View File

@ -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");
//============================================================================

View File

@ -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");
//============================================================================

View File

@ -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");
//============================================================================

View File

@ -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");

View File

@ -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

View File

@ -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");
/*****************************************************************************

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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