diff --git a/CMakeLists.txt b/CMakeLists.txt index cd3cdcb..dff74bd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,8 @@ elseif(MSVC) add_compile_options(/W4) add_compile_options(/we4840) # treat as error when passing a class to a vararg-function (probably printf-like) + # treat several kinds of truncating int<->pointer conversions as errors (for more 64bit-safety) + add_compile_options(/we4306 /we4311 /we4312 /we4302) add_compile_options(/wd4100) # unreferenced formal parameter add_compile_options(/wd4127) # conditional expression is constant add_compile_options(/wd4244) # possible loss of data diff --git a/framework/CVarSystem.h b/framework/CVarSystem.h index 1f1bd31..e0ae01c 100644 --- a/framework/CVarSystem.h +++ b/framework/CVarSystem.h @@ -182,6 +182,8 @@ private: static idCVar * staticVars; }; +static idCVar const * const staticCVarsInvalid = (const idCVar*)(uintptr_t)0xFFFFFFFF; + ID_INLINE idCVar::idCVar( const char *name, const char *value, int flags, const char *description, argCompletion_t valueCompletion ) { if ( !valueCompletion && ( flags & CVAR_BOOL ) ) { @@ -293,7 +295,7 @@ ID_INLINE void idCVar::Init( const char *name, const char *value, int flags, con this->integerValue = 0; this->floatValue = 0.0f; this->internalVar = this; - if ( staticVars != (idCVar *)0xFFFFFFFF ) { + if ( staticVars != staticCVarsInvalid ) { this->next = staticVars; staticVars = this; } else { @@ -302,11 +304,11 @@ ID_INLINE void idCVar::Init( const char *name, const char *value, int flags, con } ID_INLINE void idCVar::RegisterStaticVars( void ) { - if ( staticVars != (idCVar *)0xFFFFFFFF ) { + if ( staticVars != staticCVarsInvalid ) { for ( idCVar *cvar = staticVars; cvar; cvar = cvar->next ) { cvarSystem->Register( cvar ); } - staticVars = (idCVar *)0xFFFFFFFF; + staticVars = (idCVar *)staticCVarsInvalid; } }