mirror of
https://github.com/dhewm/dhewm3-sdk.git
synced 2024-11-21 20:21:19 +00:00
MSVC: Treat pointer truncation warnings as errors, adjust idCVar for that
All pointer<->integer conversion truncation warnings I'm aware of are now enabled for MSVC, to hopefully finally get that tool code 64bit-clean. I had to adjust the idCVar code for this - it should've been safe enough (highly unlikely that a valid pointer is exactly 0xFFFFFFFF on 64bit), but triggered those warnings - now it should behave the same as before but the warnings (which are now errors) are silenced.
This commit is contained in:
parent
03c2b379df
commit
2e2ca7c5d5
2 changed files with 7 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue