Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6451) Solaris compiler warning
Home

[Freeciv-Dev] Re: (PR#6451) Solaris compiler warning

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: brett.albertson@xxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6451) Solaris compiler warning
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 13 Oct 2003 14:39:11 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Jason Short wrote:
> [bretta - Thu Oct  9 12:00:09 2003]:
> 
> 
>>I just saw an interesting compiler warning during a build on Solaris:
>>
>>if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./../common -I./../ai -I../intl
>>-I../common/aicore -I./userdb    -g -O2 -Wall -Wpointer-arith
>>-Wcast-align -Wmissing-prototypes -Wmissing-declarations -MT srv_main.o
>>-MD -MP -MF ".deps/srv_main.Tpo" \
>>  -c -o srv_main.o `test -f 'srv_main.c' || echo './'`srv_main.c; \
>>then mv ".deps/srv_main.Tpo" ".deps/srv_main.Po"; \
>>else rm -f ".deps/srv_main.Tpo"; exit 1; \
>>fi
>>In file included from ../common/capability.h:17,
>>                 from srv_main.c:47:
>>../common/shared.h:86:1: warning: "WRAP" redefined
>>In file included from /usr/include/sys/termio.h:13,
>>                 from srv_main.c:32:
>>/usr/include/sys/termios.h:251:1: warning: this is the location of the
>>previous definition
>>
>>
>>Looks like "WRAP" is already used by termio.h.
> 
> 
> WRAP is being defined as an arbitrary integer (something do do with page
> sizes, I imagine).
> 
> Freeciv's WRAP macro could be renamed WRAP0 or FC_WRAP.

This patch renames WRAP as FC_WRAP.

jason

Index: client/mapview_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapview_common.c,v
retrieving revision 1.67
diff -u -r1.67 mapview_common.c
--- client/mapview_common.c     2003/10/13 00:48:12     1.67
+++ client/mapview_common.c     2003/10/13 21:37:58
@@ -312,13 +312,13 @@
   get_mapview_scroll_window(&xmin, &ymin, &xmax, &ymax, &xsize, &ysize);
 
   if (topo_has_flag(TF_WRAPX)) {
-    nat_x0 = WRAP(nat_x0, map.xsize);
+    nat_x0 = FC_WRAP(nat_x0, map.xsize);
   } else {
     nat_x0 = CLIP(xmin, nat_x0, xmax - xsize);
   }
 
   if (topo_has_flag(TF_WRAPY)) {
-    nat_y0 = WRAP(nat_y0, map.ysize);
+    nat_y0 = FC_WRAP(nat_y0, map.ysize);
   } else {
     nat_y0 = CLIP(ymin, nat_y0, ymax - ysize);
   }
@@ -1485,12 +1485,12 @@
    * basically necessary for the overview to be efficiently updated.  See
    * refresh_overview_viewrect(). */
   if (topo_has_flag(TF_WRAPX)) {
-    map_overview_x0 = WRAP(map_x - map.xsize / 2, map.xsize);
+    map_overview_x0 = FC_WRAP(map_x - map.xsize / 2, map.xsize);
   } else {
     map_overview_x0 = 0;
   }
   if (topo_has_flag(TF_WRAPY)) {
-    map_overview_y0 = WRAP(map_y - map.ysize / 2, map.ysize);
+    map_overview_y0 = FC_WRAP(map_y - map.ysize / 2, map.ysize);
   } else {
     map_overview_y0 = 0;
   }
@@ -1512,10 +1512,10 @@
   gui_x -= map_overview_x0;
   gui_y -= map_overview_y0;
   if (topo_has_flag(TF_WRAPX)) {
-    gui_x = WRAP(gui_x, map.xsize);
+    gui_x = FC_WRAP(gui_x, map.xsize);
   }
   if (topo_has_flag(TF_WRAPY)) {
-    gui_y = WRAP(gui_y, map.ysize);
+    gui_y = FC_WRAP(gui_y, map.ysize);
   }
   *overview_x = OVERVIEW_TILE_WIDTH * gui_x;
   *overview_y = OVERVIEW_TILE_HEIGHT * gui_y;
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.147
diff -u -r1.147 map.c
--- common/map.c        2003/10/02 17:54:57     1.147
+++ common/map.c        2003/10/13 21:37:59
@@ -1384,10 +1384,10 @@
 
   /* Wrap in X and Y directions, as needed. */
   if (topo_has_flag(TF_WRAPX)) {
-    nat_x = WRAP(nat_x, map.xsize);
+    nat_x = FC_WRAP(nat_x, map.xsize);
   }
   if (topo_has_flag(TF_WRAPY)) {
-    nat_y = WRAP(nat_y, map.ysize);
+    nat_y = FC_WRAP(nat_y, map.ysize);
   }
 
   /* Now transform things back to map coordinates. */
@@ -1454,11 +1454,11 @@
     *dy = y1 - y0;
     if (topo_has_flag(TF_WRAPX)) {
       /* Wrap dx to be in [-map.xsize/2, map.xsize/2). */
-      *dx = WRAP(*dx + map.xsize / 2, map.xsize) - map.xsize / 2;
+      *dx = FC_WRAP(*dx + map.xsize / 2, map.xsize) - map.xsize / 2;
     }
     if (topo_has_flag(TF_WRAPY)) {
       /* Wrap dy to be in [-map.ysize/2, map.ysize/2). */
-      *dy = WRAP(*dy + map.ysize / 2, map.ysize) - map.ysize / 2;
+      *dy = FC_WRAP(*dy + map.ysize / 2, map.ysize) - map.ysize / 2;
     }
 
     /* Convert the native delta vector back to a pair of map positions. */
Index: common/shared.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/shared.h,v
retrieving revision 1.118
diff -u -r1.118 shared.h
--- common/shared.h     2003/10/01 21:01:52     1.118
+++ common/shared.h     2003/10/13 21:37:59
@@ -83,7 +83,9 @@
 #endif
 #define CLIP(lower,this,upper) \
     ((this)<(lower)?(lower):(this)>(upper)?(upper):(this))
-#define WRAP(value, range)                                                  \
+
+/* Note: Solaris already has a WRAP macro that is completely different. */
+#define FC_WRAP(value, range)                                               \
     ((value) < 0                                                            \
      ? ((value) % (range) != 0 ? (value) % (range) + (range) : 0)           \
      : ((value) >= (range) ? (value) % (range) : (value)))

[Prev in Thread] Current Thread [Next in Thread]