From: Magnus Jacobsson Date: Sun, 12 Dec 2021 09:24:35 +0000 (+0100) Subject: tred: rename DIST macro to avoid shadowing X-Git-Tag: 3.0.0~107^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5db76984210e9be727e0d047da1f5fddc34cba26;p=graphviz tred: rename DIST macro to avoid shadowing The next commit in this series will include types.h which transitively includes geom.h which has another DIST macro defined. Without this change, this error would occur: FAILED: cmd/tools/CMakeFiles/tred.dir/tred.c.obj C:\tools\msys64\mingw64\bin\ccache.exe gcc -DDEMAND_LOADING=0 -DDIGCOLA -DENABLE_LTDL -DGVDLL -DORTHO -DSFDP -IC:/Users/magja/graphviz/build -IC:/Users/magja/graphviz/lib -IC:/Users/magja/graphviz/cmd/tools -IC:/Users/magja/graphviz/build/cmd/tools -IC:/Users/magja/graphviz/lib/cdt -IC:/Users/magja/graphviz/lib/cgraph -IC:/Users/magja/graphviz/lib/common -IC:/Users/magja/graphviz/lib/gvc -IC:/Users/magja/graphviz/lib/pack -IC:/Users/magja/graphviz/lib/pathplan -Werror -Wall -std=gnu99 -MD -MT cmd/tools/CMakeFiles/tred.dir/tred.c.obj -MF cmd\tools\CMakeFiles\tred.dir\tred.c.obj.d -o cmd/tools/CMakeFiles/tred.dir/tred.c.obj -c C:/Users/magja/graphviz/cmd/tools/tred.c C:/Users/magja/graphviz/cmd/tools/tred.c:38: error: "DIST" redefined [-Werror] 38 | #define DIST(ninfo,n) (ninfo[AGSEQ(n)].dist) | In file included from C:/Users/magja/graphviz/lib/common/types.h:31, from C:/Users/magja/graphviz/cmd/tools/tred.c:24: C:/Users/magja/graphviz/lib/common/geom.h:53: note: this is the location of the previous definition 53 | #define DIST(p,q) (sqrt(DIST2((p),(q)))) | --- diff --git a/cmd/tools/tred.c b/cmd/tools/tred.c index ef2764e35..8dfd526a1 100644 --- a/cmd/tools/tred.c +++ b/cmd/tools/tred.c @@ -33,7 +33,7 @@ typedef struct { } nodeinfo_t; #define ON_STACK(ninfo,n) (ninfo[AGSEQ(n)].on_stack) -#define DIST(ninfo,n) (ninfo[AGSEQ(n)].dist) +#define DISTANCE(ninfo,n) (ninfo[AGSEQ(n)].dist) #define agrootof(n) ((n)->root) #ifdef HAVE_UNISTD_H @@ -191,12 +191,12 @@ static int dfs(Agnode_t * n, nodeinfo_t* ninfo, int warn, estack_t* sp) agnameof(v), agnameof(hd)); } } - else if (DIST(ninfo,hd) == 0) { - DIST(ninfo,hd) = MIN(1,DIST(ninfo,v))+1; + else if (DISTANCE(ninfo,hd) == 0) { + DISTANCE(ninfo,hd) = MIN(1,DISTANCE(ninfo,v))+1; break; } - else if (DIST(ninfo,hd) == 1) { - DIST(ninfo,hd) = MIN(1,DIST(ninfo,v))+1; + else if (DISTANCE(ninfo,hd) == 1) { + DISTANCE(ninfo,hd) = MIN(1,DISTANCE(ninfo,v))+1; } } if (next) { @@ -216,7 +216,7 @@ static int dfs(Agnode_t * n, nodeinfo_t* ninfo, int warn, estack_t* sp) do_delete = 1; else { oldhd = hd; - if (DIST(ninfo, hd)>1) do_delete = 1; + if (DISTANCE(ninfo, hd)>1) do_delete = 1; } if(do_delete) { if(PrintRemovedEdges) fprintf(stderr,"removed edge: %s: \"%s\" -> \"%s\"\n"