Fix -Winvalid-offsetof warnings

This commit is contained in:
dhewg 2011-12-09 20:49:12 +01:00
parent 9ab9bdea8b
commit e97d328804
3 changed files with 30 additions and 30 deletions

View file

@ -214,7 +214,7 @@ type *idBlockAlloc<type,blockSize>::Alloc( void ) {
template<class type, int blockSize>
void idBlockAlloc<type,blockSize>::Free( type *t ) {
element_t *element = (element_t *)( ( (unsigned char *) t ) - ( (int) &((element_t *)0)->t ) );
element_t *element = (element_t *)( intptr_t(t) - sizeof(intptr_t) );
element->next = free;
free = element;
active--;

View file

@ -258,31 +258,31 @@ int idSimpleWindow::GetWinVarOffset( idWinVar *wv, drawWin_t* owner) {
int ret = -1;
if ( wv == &rect ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->rect;
ret = (ptrdiff_t)&this->rect - (ptrdiff_t)this;
}
if ( wv == &backColor ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->backColor;
ret = (ptrdiff_t)&this->backColor - (ptrdiff_t)this;
}
if ( wv == &matColor ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->matColor;
ret = (ptrdiff_t)&this->matColor - (ptrdiff_t)this;
}
if ( wv == &foreColor ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->foreColor;
ret = (ptrdiff_t)&this->foreColor - (ptrdiff_t)this;
}
if ( wv == &borderColor ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->borderColor;
ret = (ptrdiff_t)&this->borderColor - (ptrdiff_t)this;
}
if ( wv == &textScale ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->textScale;
ret = (ptrdiff_t)&this->textScale - (ptrdiff_t)this;
}
if ( wv == &rotate ) {
ret = (int)&( ( idSimpleWindow * ) 0 )->rotate;
ret = (ptrdiff_t)&this->rotate - (ptrdiff_t)this;
}
if ( ret != -1 ) {

View file

@ -1718,35 +1718,35 @@ int idWindow::GetWinVarOffset( idWinVar *wv, drawWin_t* owner) {
int ret = -1;
if ( wv == &rect ) {
ret = (int)&( ( idWindow * ) 0 )->rect;
ret = (ptrdiff_t)&this->rect - (ptrdiff_t)this;
}
if ( wv == &backColor ) {
ret = (int)&( ( idWindow * ) 0 )->backColor;
ret = (ptrdiff_t)&this->backColor - (ptrdiff_t)this;
}
if ( wv == &matColor ) {
ret = (int)&( ( idWindow * ) 0 )->matColor;
ret = (ptrdiff_t)&this->matColor - (ptrdiff_t)this;
}
if ( wv == &foreColor ) {
ret = (int)&( ( idWindow * ) 0 )->foreColor;
ret = (ptrdiff_t)&this->foreColor - (ptrdiff_t)this;
}
if ( wv == &hoverColor ) {
ret = (int)&( ( idWindow * ) 0 )->hoverColor;
ret = (ptrdiff_t)&this->hoverColor - (ptrdiff_t)this;
}
if ( wv == &borderColor ) {
ret = (int)&( ( idWindow * ) 0 )->borderColor;
ret = (ptrdiff_t)&this->borderColor - (ptrdiff_t)this;
}
if ( wv == &textScale ) {
ret = (int)&( ( idWindow * ) 0 )->textScale;
ret = (ptrdiff_t)&this->textScale - (ptrdiff_t)this;
}
if ( wv == &rotate ) {
ret = (int)&( ( idWindow * ) 0 )->rotate;
ret = (ptrdiff_t)&this->rotate - (ptrdiff_t)this;
}
if ( ret != -1 ) {
@ -3776,35 +3776,35 @@ void idWindow::FixupTransitions() {
transitions[i].data = NULL;
if ( dw && ( dw->win || dw->simp ) ){
if ( dw->win ) {
if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->rect ) {
if ( transitions[i].offset == (ptrdiff_t)&this->rect - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->rect;
} else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->backColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->backColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->backColor;
} else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->matColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->matColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->matColor;
} else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->foreColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->foreColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->foreColor;
} else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->borderColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->borderColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->borderColor;
} else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->textScale ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->textScale - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->textScale;
} else if ( transitions[i].offset == (int)&( ( idWindow * ) 0 )->rotate ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->rotate - (ptrdiff_t)this ) {
transitions[i].data = &dw->win->rotate;
}
} else {
if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->rect ) {
if ( transitions[i].offset == (ptrdiff_t)&this->rect - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->rect;
} else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->backColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->backColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->backColor;
} else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->matColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->matColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->matColor;
} else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->foreColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->foreColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->foreColor;
} else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->borderColor ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->borderColor - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->borderColor;
} else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->textScale ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->textScale - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->textScale;
} else if ( transitions[i].offset == (int)&( ( idSimpleWindow * ) 0 )->rotate ) {
} else if ( transitions[i].offset == (ptrdiff_t)&this->rotate - (ptrdiff_t)this ) {
transitions[i].data = &dw->simp->rotate;
}
}