1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2026-01-09 04:49:04 +00:00

Add a helper function voidp to silence GCC warnings about %p.

We must fully qualify calls to `hr::voidp` because the expression
`voidp(x)` is ambiguous or worse. "/usr/include/zconf.h" defines
`voidp` in the global namespace as a typedef for `void*`.
We don't want an unsafe functional-style cast to `void*`;
we want to call our nice safe helper function. So we qualify the name.
This commit is contained in:
Arthur O'Dwyer
2020-02-22 21:48:46 -05:00
parent 13bf666e29
commit 7a706478dc
10 changed files with 53 additions and 48 deletions

View File

@@ -85,7 +85,7 @@ struct hrmap_hyperbolic : hrmap_standard {
heptagon *getOrigin() override { return origin; }
~hrmap_hyperbolic() {
// verifycells(origin);
// printf("Deleting hyperbolic map: %p\n", this);
// printf("Deleting hyperbolic map: %p\n", hr::voidp(this));
clearfrom(origin);
}
void verify() override { verifycells(origin); }
@@ -203,7 +203,7 @@ EX cell *createMov(cell *c, int d) {
else if(GOLDBERG) {
gp::extend_map(c, d);
if(!c->move(d)) {
printf("extend failed to create for %p/%d\n", c, d);
printf("extend failed to create for %p/%d\n", hr::voidp(c), d);
exit(1);
}
hybrid::link();
@@ -314,9 +314,9 @@ EX void initcells() {
EX void clearcell(cell *c) {
if(!c) return;
DEBB(DF_MEMORY, (format("c%d %p\n", c->type, c)));
DEBB(DF_MEMORY, (format("c%d %p\n", c->type, hr::voidp(c))));
for(int t=0; t<c->type; t++) if(c->move(t)) {
DEBB(DF_MEMORY, (format("mov %p [%p] S%d\n", c->move(t), c->move(t)->move(c->c.spin(t)), c->c.spin(t))));
DEBB(DF_MEMORY, (format("mov %p [%p] S%d\n", hr::voidp(c->move(t)), hr::voidp(c->move(t)->move(c->c.spin(t))), c->c.spin(t))));
if(c->move(t)->move(c->c.spin(t)) != NULL &&
c->move(t)->move(c->c.spin(t)) != c) {
DEBB(DF_MEMORY | DF_ERROR, (format("cell error: type = %d %d -> %d\n", c->type, t, c->c.spin(t))));
@@ -324,7 +324,7 @@ EX void clearcell(cell *c) {
}
c->move(t)->move(c->c.spin(t)) = NULL;
}
DEBB(DF_MEMORY, (format("DEL %p\n", c)));
DEBB(DF_MEMORY, (format("DEL %p\n", hr::voidp(c))));
tailored_delete(c);
}
@@ -416,7 +416,7 @@ EX void verifycell(cell *c) {
if(c2) {
if(BITRUNCATED && c == c->master->c7) verifycell(c2);
if(c2->move(c->c.spin(i)) && c2->move(c->c.spin(i)) != c) {
printf("cell error %p:%d [%d] %p:%d [%d]\n", c, i, c->type, c2, c->c.spin(i), c2->type);
printf("cell error %p:%d [%d] %p:%d [%d]\n", hr::voidp(c), i, c->type, hr::voidp(c2), c->c.spin(i), c2->type);
exit(1);
}
}
@@ -426,7 +426,7 @@ EX void verifycell(cell *c) {
EX void verifycells(heptagon *at) {
if(GOLDBERG || IRREGULAR || arcm::in()) return;
for(int i=0; i<at->type; i++) if(at->move(i) && at->move(i)->move(at->c.spin(i)) && at->move(i)->move(at->c.spin(i)) != at) {
printf("hexmix error %p [%d s=%d] %p %p\n", at, i, at->c.spin(i), at->move(i), at->move(i)->move(at->c.spin(i)));
printf("hexmix error %p [%d s=%d] %p %p\n", hr::voidp(at), i, at->c.spin(i), hr::voidp(at->move(i)), hr::voidp(at->move(i)->move(at->c.spin(i))));
}
if(!sphere && !quotient)
for(int i=0; i<S7; i++) if(at->move(i) && at->c.spin(i) == 0 && at->s != hsOrigin)