From b57ac76e4afbc2b1567c57eac0b0918a7c26aab5 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 11 Oct 2020 08:59:53 -0700 Subject: [PATCH] make debugging code in partition.c visible to the compiler This ensures it will trigger a compiler error if it is not updated when code it depends on changes, while still preserving the compiler's ability to optimize it out. This also squashes a -Wunused warning related to a variable only used for debugging. --- lib/ortho/partition.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/ortho/partition.c b/lib/ortho/partition.c index 029787e45..af104c315 100644 --- a/lib/ortho/partition.c +++ b/lib/ortho/partition.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #ifndef DEBUG @@ -725,26 +726,32 @@ partition (cell* cells, int ncells, int* nrects, boxf bb) boxf* vert_decomp = N_NEW(ntraps, boxf); int nt; - /* fprintf (stderr, "cells = %d segs = %d traps = %d\n", ncells, nsegs, ntraps); */ + if (DEBUG) { + fprintf (stderr, "cells = %d segs = %d traps = %d\n", ncells, nsegs, ntraps); + } genSegments (cells, ncells, bb, segs, 0); -#if 0 -fprintf (stderr, "%d\n\n", ncells+1); -for (i = 1; i<= nsegs; i++) { - if (i%4 == 1) fprintf(stderr, "4\n"); - fprintf (stderr, "%f %f\n", segs[i].v0.x, segs[i].v0.y); - if (i%4 == 0) fprintf(stderr, "\n"); -} -#endif + if (DEBUG) { + fprintf (stderr, "%d\n\n", ncells+1); + for (i = 1; i<= nsegs; i++) { + if (i%4 == 1) fprintf(stderr, "4\n"); + fprintf (stderr, "%f %f\n", segs[i].v0.x, segs[i].v0.y); + if (i%4 == 0) fprintf(stderr, "\n"); + } + } srand48(173); generateRandomOrdering (nsegs, permute); nt = construct_trapezoids(nsegs, segs, permute, ntraps, trs); - /* fprintf (stderr, "hor traps = %d\n", nt); */ + if (DEBUG) { + fprintf (stderr, "hor traps = %d\n", nt); + } hd_size = monotonate_trapezoids (nsegs, segs, trs, 0, hor_decomp); genSegments (cells, ncells, bb, segs, 1); generateRandomOrdering (nsegs, permute); nt = construct_trapezoids(nsegs, segs, permute, ntraps, trs); - /* fprintf (stderr, "ver traps = %d\n", nt); */ + if (DEBUG) { + fprintf (stderr, "ver traps = %d\n", nt); + } vd_size = monotonate_trapezoids (nsegs, segs, trs, 1, vert_decomp); rs = N_NEW (hd_size*vd_size, boxf); -- 2.40.0