]> granicus.if.org Git - graphviz/commitdiff
tred: rename DIST macro to avoid shadowing
authorMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sun, 12 Dec 2021 09:24:35 +0000 (10:24 +0100)
committerMagnus Jacobsson <Magnus.Jacobsson@berotec.se>
Sun, 26 Dec 2021 06:59:15 +0000 (07:59 +0100)
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))))
      |

cmd/tools/tred.c

index ef2764e3565bb36c9ded02794c4738d6a6d20aac..8dfd526a17f7a160f6de8c68b8e624f7af1fe408 100644 (file)
@@ -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"