[AD] Type-pun warnings with GCC 4.1 |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
When building the latest SVN from SF using GCC 4.1.1, I get some type-pun
warnings when compiling dat.c and grabber.c (which would invariably cause
failure with --enable-strictwarn). The attached patch fixes dat.c, but
grabber.c may prove to be a little trickier. For reference, the lines are
516, 1743, and 3271. The first of which is below:
static void get_selection_info(DATAFILE **dat, DATAFILE ***parent)
{
if ((SELECTED_ITEM <= 0) || (SELECTED_ITEM >= data_count)) {
*dat = NULL;
*parent = &datafile;
}
else {
*dat = data[SELECTED_ITEM].dat;
if ((*dat)->type == DAT_FILE)
*parent = (DATAFILE **)&(*dat)->dat; // error here!
else
*parent = data[SELECTED_ITEM].parent;
}
}
Unfortunately it's not so easy to fix, because you can't put it into a temp
DATAFILE* var and pass the address to that since the function returns, making
the pointer invalid. As well, putting the pointer in a DATAFILE** var would
probably cause the same warning message. Ideas?
Index: tools/dat.c
===================================================================
--- tools/dat.c (revision 7316)
+++ tools/dat.c (working copy)
@@ -432,8 +432,10 @@
}
else {
if ((*dat)[i].type == DAT_FILE) {
+ DATAFILE *dattmp = (*dat)[i].dat;
strcat(tmp, "/");
- do_delete((DATAFILE **)(&((*dat)[i].dat)), tmp);
+ do_delete(&dattmp, tmp);
+ (*dat)[i].dat = dattmp;
}
}
}
@@ -681,8 +683,10 @@
}
else {
if ((*dat)[i].type == DAT_FILE) {
+ DATAFILE *dattmp = (*dat)[i].dat;
strcat(tmp, "/");
- do_setpal((DATAFILE **)(&((*dat)[i].dat)), tmp);
+ do_setpal(&dattmp, tmp);
+ (*dat)[i].dat = dattmp;
}
}
}