[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (089fbaf59c78fe75475db737e7e2827cd745d570)



The branch, master has been updated
       via  089fbaf59c78fe75475db737e7e2827cd745d570 (commit)
      from  5f0f788dc12a10a3c01ade7cf00d5ed63922ca47 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 configure.ac                     |   25 +++++++-
 src/action.c                     |   50 ++++++++++----
 src/autoplace.c                  |    9 ++-
 src/autoroute.c                  |  125 ++++++++++++++++++++++------------
 src/change.c                     |    2 +-
 src/create.c                     |   14 ++--
 src/dbus-pcbmain.c               |   24 ++++---
 src/draw.c                       |   12 ++--
 src/drill.c                      |    6 +-
 src/edif.y                       |   46 +++++--------
 src/file.c                       |   30 ++++----
 src/find.c                       |   64 +++++++++---------
 src/free_atexit.c                |    2 +-
 src/global.h                     |    3 +-
 src/heap.c                       |    4 +-
 src/hid.h                        |   10 ++-
 src/hid/bom/bom.c                |   56 ++++++++--------
 src/hid/common/actions.c         |    6 +-
 src/hid/common/draw_helpers.c    |    8 +-
 src/hid/common/extents.c         |    4 +-
 src/hid/common/flags.c           |    4 +-
 src/hid/common/hid_resource.c    |    8 +-
 src/hid/common/hidinit.c         |    9 ++-
 src/hid/common/hidnogui.c        |    2 +-
 src/hid/gcode/gcode.c            |   14 ++--
 src/hid/gerber/gerber.c          |  140 ++++++++++++++++++++++----------------
 src/hid/gtk/gtkhid-gdk.c         |   22 +++---
 src/hid/gtk/gtkhid-main.c        |   20 +++---
 src/hid/gtk/gui-command-window.c |    2 +-
 src/hid/gtk/gui-config.c         |   36 +++++-----
 src/hid/gtk/gui-dialog-print.c   |   24 +++---
 src/hid/gtk/gui-dialog-size.c    |   66 +++++++++++++++---
 src/hid/gtk/gui-dialog.c         |   22 +++---
 src/hid/gtk/gui-drc-window.c     |   26 ++++----
 src/hid/gtk/gui-library-window.c |    8 +-
 src/hid/gtk/gui-log-window.c     |    2 +-
 src/hid/gtk/gui-misc.c           |   20 +++---
 src/hid/gtk/gui-netlist-window.c |    4 +-
 src/hid/gtk/gui-output-events.c  |    2 +-
 src/hid/gtk/gui-pinout-preview.c |    8 +-
 src/hid/gtk/gui-top-window.c     |   38 +++++-----
 src/hid/gtk/gui-utils.c          |   10 ++--
 src/hid/gtk/gui.h                |   16 ++--
 src/hid/nelma/nelma.c            |   12 ++--
 src/hid/png/png.c                |   10 ++--
 src/hid/ps/eps.c                 |  136 ++++++++++++++++++++++---------------
 src/hid/ps/ps.c                  |    6 +-
 src/insert.c                     |   22 +++---
 src/intersect.c                  |    8 +-
 src/main.c                       |    4 +-
 src/misc.c                       |    6 +-
 src/move.c                       |  120 ++++++++++++++++----------------
 src/mtspace.c                    |   87 +++++++++++++-----------
 src/mymem.c                      |   48 +++++++-------
 src/netlist.c                    |    2 +-
 src/parse_l.l                    |    4 +-
 src/parse_y.y                    |    7 +-
 src/polygon.c                    |   32 ++++----
 src/polygon1.c                   |  114 +++++++++++++++---------------
 src/puller.c                     |   12 ++--
 src/rats.c                       |   26 ++++----
 src/rats.h                       |    2 +-
 src/report.c                     |    2 +-
 src/rtree.c                      |   10 ++--
 src/toporouter.c                 |   66 +++++++++---------
 src/undo.c                       |   24 +++---
 src/vector.c                     |   20 +++---
 src/vendor.c                     |    4 +-
 68 files changed, 987 insertions(+), 800 deletions(-)


=================
 Commit Messages
=================

commit 089fbaf59c78fe75475db737e7e2827cd745d570
Author: Newell Jensen <pillar2012@xxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Initial C++ compatibility patch
    
    Doesn't cover lesstif or batch hids.  Makes source code build without
    warnings on C, and build with warnings on C++.

:100644 100644 ca2dbe4... e405819... M	configure.ac
:100644 100644 5acd3fd... fd90b19... M	src/action.c
:100644 100644 ed2014a... e1461c6... M	src/autoplace.c
:100644 100644 976ef09... b2cbab4... M	src/autoroute.c
:100644 100644 2545d84... cb53b47... M	src/change.c
:100644 100644 07de918... f942c40... M	src/create.c
:100644 100644 83b2e97... 07e68c0... M	src/dbus-pcbmain.c
:100644 100644 e0890da... bb212e9... M	src/draw.c
:100644 100644 1f1d770... a7a908b... M	src/drill.c
:100644 100644 d9dbd8e... da33c9b... M	src/edif.y
:100644 100644 9e38217... 1df23d5... M	src/file.c
:100644 100644 613629a... 615659d... M	src/find.c
:100644 100644 501775c... 6527a46... M	src/free_atexit.c
:100644 100644 bb78abc... 0420a18... M	src/global.h
:100644 100644 fee6412... 9e0f35e... M	src/heap.c
:100644 100644 94734ba... b13e75b... M	src/hid.h
:100644 100644 04ad123... 661b592... M	src/hid/bom/bom.c
:100644 100644 d1e87f5... 43c50f8... M	src/hid/common/actions.c
:100644 100644 1c7ead9... dc1f60f... M	src/hid/common/draw_helpers.c
:100644 100644 e8bd8ab... 0f51b47... M	src/hid/common/extents.c
:100644 100644 30859fb... 9b53328... M	src/hid/common/flags.c
:100644 100644 d5ba274... 11f1171... M	src/hid/common/hid_resource.c
:100644 100644 bb1a66b... 9c4f8ee... M	src/hid/common/hidinit.c
:100644 100644 08adb26... fd86b6a... M	src/hid/common/hidnogui.c
:100644 100644 f1bdcea... 64d45cb... M	src/hid/gcode/gcode.c
:100644 100644 85e01f3... 63344b3... M	src/hid/gerber/gerber.c
:100644 100644 0a2cc59... 6ea9f9b... M	src/hid/gtk/gtkhid-gdk.c
:100644 100644 8bbf3eb... 169884e... M	src/hid/gtk/gtkhid-main.c
:100644 100644 b97ec0b... d865dee... M	src/hid/gtk/gui-command-window.c
:100644 100644 36277eb... 516feb5... M	src/hid/gtk/gui-config.c
:100644 100644 0c50aed... 9ced77b... M	src/hid/gtk/gui-dialog-print.c
:100644 100644 8409ba5... a5b5888... M	src/hid/gtk/gui-dialog-size.c
:100644 100644 80c1157... bb934bd... M	src/hid/gtk/gui-dialog.c
:100644 100644 e2fa201... a708193... M	src/hid/gtk/gui-drc-window.c
:100644 100644 f54d914... eb366ba... M	src/hid/gtk/gui-library-window.c
:100644 100644 ae25ed7... a91f346... M	src/hid/gtk/gui-log-window.c
:100644 100644 e3316aa... 1c55a99... M	src/hid/gtk/gui-misc.c
:100644 100644 a5e38d1... b60b8ba... M	src/hid/gtk/gui-netlist-window.c
:100644 100644 2e820a3... 349f91b... M	src/hid/gtk/gui-output-events.c
:100644 100644 212d37a... fc69639... M	src/hid/gtk/gui-pinout-preview.c
:100644 100644 f2cdb99... 4186d85... M	src/hid/gtk/gui-top-window.c
:100644 100644 3d93d19... 5db7b42... M	src/hid/gtk/gui-utils.c
:100644 100644 d2a76ce... df30955... M	src/hid/gtk/gui.h
:100644 100644 5f6ebc7... 60f5b37... M	src/hid/nelma/nelma.c
:100644 100644 32639c8... 06e22bb... M	src/hid/png/png.c
:100644 100644 83ce780... 49a19c7... M	src/hid/ps/eps.c
:100644 100644 eacf826... 7c286cc... M	src/hid/ps/ps.c
:100644 100644 5e62463... 7e9ebf2... M	src/insert.c
:100644 100644 7389ba9... e7612e9... M	src/intersect.c
:100644 100644 735fde7... 3fff933... M	src/main.c
:100644 100644 e1e14c8... 13c7398... M	src/misc.c
:100644 100644 cbb2e3d... 5e3913c... M	src/move.c
:100644 100644 3640f5c... 9d593e8... M	src/mtspace.c
:100644 100644 09cb6ab... 24f20a2... M	src/mymem.c
:100644 100644 4a26bc9... 0c004f9... M	src/netlist.c
:100644 100644 9799250... 57cd1c6... M	src/parse_l.l
:100644 100644 7aa7b80... d0f31aa... M	src/parse_y.y
:100644 100644 72d92c9... c552f3c... M	src/polygon.c
:100644 100644 468c139... 8e9aa24... M	src/polygon1.c
:100644 100644 66a5a03... 8e56f0b... M	src/puller.c
:100644 100644 3e9d6ee... 24be309... M	src/rats.c
:100644 100644 eb928d4... 3d70f27... M	src/rats.h
:100644 100644 f0668d9... 9135e0d... M	src/report.c
:100644 100644 f44672c... e2ef1ee... M	src/rtree.c
:100644 100644 bfd494a... 28a3764... M	src/toporouter.c
:100644 100644 5226c53... b14e3ec... M	src/undo.c
:100644 100644 169afd3... c039b89... M	src/vector.c
:100644 100644 a296aa1... 5b7f5eb... M	src/vendor.c

=========
 Changes
=========

commit 089fbaf59c78fe75475db737e7e2827cd745d570
Author: Newell Jensen <pillar2012@xxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Initial C++ compatibility patch
    
    Doesn't cover lesstif or batch hids.  Makes source code build without
    warnings on C, and build with warnings on C++.

diff --git a/configure.ac b/configure.ac
index ca2dbe4..e405819 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1017,7 +1017,7 @@ LIBS="$LIBS $XM_LIBS $DBUS_LIBS $X_LIBS $GLIB_LIBS $GTK_LIBS $DMALLOC_LIBS $GD_L
 # if we have gcc then add -Wall
 if test "x$GCC" = "xyes"; then
 	# see about adding some extra checks if the compiler takes them
-	for flag in -Wall -Wdeclaration-after-statement ; do
+	for flag in -Wall ; do
 		case " ${CFLAGS} " in
 			*\ ${flag}\ *)
 				# flag is already present
@@ -1039,6 +1039,29 @@ fi
 
 CXXFLAGS="$CFLAGS"
 
+# Now add C-specific flags
+if test "x$GCC" = "xyes"; then
+	# see about adding some extra checks if the compiler takes them
+	for flag in -Wdeclaration-after-statement ; do
+		case " ${CFLAGS} " in
+			*\ ${flag}\ *)
+				# flag is already present
+				;;
+			*)
+				AC_MSG_CHECKING([if the compiler accepts ${flag}])
+				ac_save_CFLAGS="$CFLAGS"
+				CFLAGS="$CFLAGS ${flag}"
+				AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
+					[AC_MSG_RESULT([yes])],
+					[AC_MSG_RESULT([no])
+					 CFLAGS="$ac_save_CFLAGS"
+					]
+				)
+				;;
+		esac
+	done
+fi
+
 # See if we are building gcc with C++.
 AC_ARG_ENABLE(build-with-cxx,
 [  --enable-build-with-cxx build with C++ compiler instead of C compiler],
diff --git a/src/action.c b/src/action.c
index 5acd3fd..fd90b19 100644
--- a/src/action.c
+++ b/src/action.c
@@ -1495,7 +1495,7 @@ NotifyMode (void)
 		{
 		  /* Create POLYAREAs from the original polygon
 		   * and the new hole polygon */
-		  original = PolygonToPoly (Crosshair.AttachedObject.Ptr2);
+		  original = PolygonToPoly ((PolygonType *)Crosshair.AttachedObject.Ptr2);
 		  new_hole = PolygonToPoly (&Crosshair.AttachedPolygon);
 
 		  /* Subtract the hole from the original polygon shape */
@@ -1506,7 +1506,7 @@ NotifyMode (void)
 		   */
 		  SaveUndoSerialNumber ();
 		  Flags = ((PolygonType *)Crosshair.AttachedObject.Ptr2)->Flags;
-		  PolyToPolygonsOnLayer (PCB->Data, Crosshair.AttachedObject.Ptr1,
+		  PolyToPolygonsOnLayer (PCB->Data, (LayerType *)Crosshair.AttachedObject.Ptr1,
 					 result, Flags);
 		  RemoveObject (POLYGON_TYPE,
 				Crosshair.AttachedObject.Ptr1,
@@ -2654,6 +2654,27 @@ the crosshair steps along the grid.
 
 %end-doc */
 
+static enum crosshair_shape
+CrosshairShapeIncrement (enum crosshair_shape shape)
+{
+  switch(shape)
+    {
+    case Basic_Crosshair_Shape:
+      shape = Union_Jack_Crosshair_Shape;
+      break;
+    case Union_Jack_Crosshair_Shape:
+      shape = Dozen_Crosshair_Shape;
+      break;
+    case Dozen_Crosshair_Shape:
+      shape = Crosshair_Shapes_Number;
+      break;
+    case Crosshair_Shapes_Number:
+      shape = Basic_Crosshair_Shape;
+      break;
+    }
+  return shape;
+}
+
 static int
 ActionDisplay (int argc, char **argv, int childX, int childY)
 {
@@ -2735,7 +2756,8 @@ ActionDisplay (int argc, char **argv, int childX, int childY)
 	  break;
 
 	case F_CycleCrosshair:
-	  Crosshair.shape++;
+	  //Crosshair.shape++;
+	  Crosshair.shape = CrosshairShapeIncrement(Crosshair.shape);
 	  if (Crosshair_Shapes_Number == Crosshair.shape)
 	    Crosshair.shape = Basic_Crosshair_Shape;
 	  break;
@@ -3368,10 +3390,10 @@ ActionRenumber (int argc, char **argv, int x, int y)
    *
    * We'll actually renumber things in the 2nd pass.
    */
-  element_list = calloc (PCB->Data->ElementN, sizeof (ElementTypePtr));
-  locked_element_list = calloc (PCB->Data->ElementN, sizeof (ElementTypePtr));
-  was = calloc (PCB->Data->ElementN, sizeof (char *));
-  is = calloc (PCB->Data->ElementN, sizeof (char *));
+  element_list = (ElementType **)calloc (PCB->Data->ElementN, sizeof (ElementTypePtr));
+  locked_element_list = (ElementType **)calloc (PCB->Data->ElementN, sizeof (ElementTypePtr));
+  was = (char **)calloc (PCB->Data->ElementN, sizeof (char *));
+  is = (char **)calloc (PCB->Data->ElementN, sizeof (char *));
   if (element_list == NULL || locked_element_list == NULL || was == NULL
       || is == NULL)
     {
@@ -3441,7 +3463,7 @@ ActionRenumber (int argc, char **argv, int x, int y)
   unique = TEST_FLAG (UNIQUENAMEFLAG, PCB);
   CLEAR_FLAG (UNIQUENAMEFLAG, PCB);
 
-  cnt_list = calloc (cnt_list_sz, sizeof (struct _cnt_list));
+  cnt_list = (struct _cnt_list *)calloc (cnt_list_sz, sizeof (struct _cnt_list));
   for (i = 0; i < cnt; i++)
     {
       /* If there is no refdes, maybe just spit out a warning */
@@ -3464,7 +3486,7 @@ ActionRenumber (int argc, char **argv, int x, int y)
 	  if (j == cnt_list_sz)
 	    {
 	      cnt_list_sz += 100;
-	      cnt_list = realloc (cnt_list, cnt_list_sz);
+	      cnt_list = (struct _cnt_list *)realloc (cnt_list, cnt_list_sz);
 	      if (cnt_list == NULL)
 		{
 		  fprintf (stderr, "realloc failed() in %s\n", __FUNCTION__);
@@ -3508,7 +3530,7 @@ ActionRenumber (int argc, char **argv, int x, int y)
 		  sz++;
 		  tmpi = tmpi / 10;
 		}
-	      tmps = malloc (sz * sizeof (char));
+	      tmps = (char *)malloc (sz * sizeof (char));
 	      sprintf (tmps, "%s%d", cnt_list[j].name, cnt_list[j].cnt);
 
 	      /* 
@@ -3598,7 +3620,7 @@ ActionRenumber (int argc, char **argv, int x, int y)
 		    {
 		      free (PCB->NetlistLib.Menu[i].Entry[j].ListEntry);
 		      PCB->NetlistLib.Menu[i].Entry[j].ListEntry =
-			malloc ((strlen (is[k]) + strlen (pin) +
+			(char *)malloc ((strlen (is[k]) + strlen (pin) +
 				 2) * sizeof (char));
 		      sprintf (PCB->NetlistLib.Menu[i].Entry[j].ListEntry,
 			       "%s-%s", is[k], pin);
@@ -6063,8 +6085,8 @@ Selects the given buffer to be the current paste buffer.
 static int
 ActionPasteBuffer (int argc, char **argv, int x, int y)
 {
-  char *function = argc ? argv[0] : "";
-  char *sbufnum = argc > 1 ? argv[1] : "";
+  char *function = argc ? argv[0] : (char *)"";
+  char *sbufnum = argc > 1 ? argv[1] : (char *)"";
   char *name;
   static char *default_file = NULL;
   int free_name = 0;
@@ -7870,7 +7892,7 @@ ActionImport (int argc, char **argv, int x, int y)
 	  cmd[i++] = "-f";
 	  cmd[i++] = user_makefile;
 	}
-      cmd[i++] = user_target ? user_target : "pcb_import";
+      cmd[i++] = user_target ? user_target : (char *)"pcb_import";
       cmd[i++] = NULL;
 
       if (pcb_spawnvp (cmd))
diff --git a/src/autoplace.c b/src/autoplace.c
index ed2014a..e1461c6 100644
--- a/src/autoplace.c
+++ b/src/autoplace.c
@@ -132,12 +132,13 @@ typedef struct
 }
 ElementPtrListType;
 
+enum ewhich
+  { SHIFT, ROTATE, EXCHANGE };
+
 typedef struct
 {
   ElementTypePtr element;
-  enum
-  { SHIFT, ROTATE, EXCHANGE }
-  which;
+  enum ewhich which;
   LocationType DX, DY;		/* for shift */
   BYTE rotate;			/* for rotate/flip */
   ElementTypePtr other;		/* for exchange */
@@ -528,7 +529,7 @@ ComputeCost (NetListTypePtr Nets, double T0, double T)
       boxpp = (struct ebox **)
 	GetPointerMemory (TEST_FLAG (ONSOLDERFLAG, element) ?
 			  &seboxes : &ceboxes);
-      *boxpp = malloc (sizeof (**boxpp));
+      *boxpp = (struct ebox *)malloc (sizeof (**boxpp));
       if (*boxpp == NULL ) 
 	{
 	  fprintf (stderr, "malloc() failed in %s\n", __FUNCTION__);
diff --git a/src/autoroute.c b/src/autoroute.c
index 976ef09..b2cbab4 100644
--- a/src/autoroute.c
+++ b/src/autoroute.c
@@ -103,6 +103,42 @@ RCSID ("$Id$");
 //#define DEBUG_SHOW_ZIGZAG
 */
 
+static direction_t
+directionIncrement(direction_t dir)
+{
+  switch(dir)
+  {
+  case NORTH:
+    dir = EAST;
+    break;
+  case EAST:
+    dir = SOUTH;
+    break;
+  case SOUTH:
+    dir = WEST;
+    break;
+  case WEST:
+    dir = NE;
+    break;
+  case NE:
+    dir = SE;
+    break;
+  case SE:
+    dir = SW;
+    break;
+  case SW:
+    dir = NW;
+    break;
+  case NW:
+    dir = ALL;
+    break;
+  case ALL:
+    dir = NORTH;
+    break;
+  }
+return dir;
+}
+
 static hidGC ar_gc = 0;
 
 #define EXPENSIVE 3e28
@@ -185,9 +221,18 @@ typedef enum
 { NO_CONFLICT = 0, LO_CONFLICT = 1, HI_CONFLICT = 2 }
 conflict_t;
 
+typedef struct routebox_list
+{
+  struct routebox *next, *prev;
+}routebox_list;
+
+typedef enum etype
+  { PAD, PIN, VIA, VIA_SHADOW, LINE, OTHER, EXPANSION_AREA, PLANE, THERMAL }
+  etype;
+
 typedef struct routebox
 {
-  const BoxType box, sbox;
+  BoxType box, sbox;
   union
   {
     PadTypePtr pad;
@@ -202,9 +247,7 @@ typedef struct routebox
   parent;
   unsigned short group;
   unsigned short layer;
-  enum
-  { PAD, PIN, VIA, VIA_SHADOW, LINE, OTHER, EXPANSION_AREA, PLANE, THERMAL }
-  type;
+  etype type;
   struct
   {
     unsigned nonstraight:1;
@@ -263,11 +306,7 @@ typedef struct routebox
   /* the direction this came from, if any */
   direction_t came_from;
   /* circular lists with connectivity information. */
-  struct routebox_list
-  {
-    struct routebox *next, *prev;
-  }
-  same_net, same_subnet, original_subnet, different_net;
+  routebox_list same_net, same_subnet, original_subnet, different_net;
 }
 routebox_t;
 
@@ -609,7 +648,7 @@ AddPin (PointerListType layergroupboxes[], PinTypePtr pin, bool is_via,
   for (i = 0; i < max_group; i++)
     {
       rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[i]);
-      *rbpp = malloc (sizeof (**rbpp));
+      *rbpp = (routebox_t *)malloc (sizeof (**rbpp));
       memset ((void *) *rbpp, 0, sizeof (**rbpp));
       (*rbpp)->group = i;
       ht = HALF_THICK (MAX (pin->Thickness, pin->DrillingHole));
@@ -657,7 +696,7 @@ AddPad (PointerListType layergroupboxes[],
   assert (PCB->LayerGroups.Number[layergroup] > 0);
   rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[layergroup]);
   assert (rbpp);
-  *rbpp = malloc (sizeof (**rbpp));
+  *rbpp = (routebox_t *)malloc (sizeof (**rbpp));
   assert (*rbpp);
   memset (*rbpp, 0, sizeof (**rbpp));
   (*rbpp)->group = layergroup;
@@ -691,7 +730,7 @@ AddLine (PointerListType layergroupboxes[], int layergroup, LineTypePtr line,
   assert (PCB->LayerGroups.Number[layergroup] > 0);
 
   rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[layergroup]);
-  *rbpp = malloc (sizeof (**rbpp));
+  *rbpp = (routebox_t *)malloc (sizeof (**rbpp));
   memset (*rbpp, 0, sizeof (**rbpp));
   (*rbpp)->group = layergroup;
   init_const_box (*rbpp,
@@ -739,7 +778,7 @@ AddIrregularObstacle (PointerListType layergroupboxes[],
   assert (PCB->LayerGroups.Number[layergroup] > 0);
 
   rbpp = (routebox_t **) GetPointerMemory (&layergroupboxes[layergroup]);
-  *rbpp = malloc (sizeof (**rbpp));
+  *rbpp = (routebox_t *)malloc (sizeof (**rbpp));
   memset (*rbpp, 0, sizeof (**rbpp));
   (*rbpp)->group = layergroup;
   init_const_box (*rbpp, X1, Y1, X2, Y2, keep);
@@ -942,7 +981,7 @@ CreateRouteData ()
 	}
     }
   /* create routedata */
-  rd = malloc (sizeof (*rd));
+  rd = (routedata_t *)malloc (sizeof (*rd));
   memset ((void *) rd, 0, sizeof (*rd));
   /* create default style */
   rd->defaultstyle.Thick = Settings.LineThickness;
@@ -1059,24 +1098,24 @@ CreateRouteData ()
 	      {
 	      case PAD_TYPE:
 		rb =
-		  AddPad (layergroupboxes, connection->ptr1,
-			  connection->ptr2, rd->styles[j]);
+		  AddPad (layergroupboxes, (ElementType *)connection->ptr1,
+			  (PadType *)connection->ptr2, rd->styles[j]);
 		break;
 	      case PIN_TYPE:
 		rb =
-		  AddPin (layergroupboxes, connection->ptr2, false,
+		  AddPin (layergroupboxes, (PinType *)connection->ptr2, false,
 			  rd->styles[j]);
 		break;
 	      case VIA_TYPE:
 		rb =
-		  AddPin (layergroupboxes, connection->ptr2, true,
+		  AddPin (layergroupboxes, (PinType *)connection->ptr2, true,
 			  rd->styles[j]);
 		break;
 	      case POLYGON_TYPE:
 		rb =
 		  AddPolygon (layergroupboxes,
-			      GetLayerNumber (PCB->Data, connection->ptr1),
-			      connection->ptr2, rd->styles[j]);
+			      GetLayerNumber (PCB->Data, (LayerType *)connection->ptr1),
+			      (struct polygon_st *)connection->ptr2, rd->styles[j]);
 		break;
 	      }
 	  assert (rb);
@@ -1706,7 +1745,7 @@ CreateEdge (routebox_t * rb,
 {
   edge_t *e;
   assert (__routebox_is_good (rb));
-  e = malloc (sizeof (*e));
+  e = (edge_t *)malloc (sizeof (*e));
   memset ((void *) e, 0, sizeof (*e));
   assert (e);
   e->rb = rb;
@@ -2757,7 +2796,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
   if (e->expand_dir == NE || e->expand_dir == SE ||
       e->expand_dir == SW || e->expand_dir == NW)
     {
-      BoxType *fb = (BoxType *) & fake.sbox;
+      BoxType *fb = (BoxType *) &fake.sbox;
       memset (&fake, 0, sizeof (fake));
       *fb = e->rb->sbox;
       fake.flags.fixed = 1;	/* this stops expansion there */
@@ -2766,7 +2805,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
 #ifndef NDEBUG
       /* the routbox_is_good checker wants a lot more! */
       fake.flags.inited = 1;
-      fb = (BoxType *) & fake.box;
+      fb = (BoxType *) &fake.box;
       *fb = e->rb->sbox;
       fake.same_net.next = fake.same_net.prev = &fake;
       fake.same_subnet.next = fake.same_subnet.prev = &fake;
@@ -2778,7 +2817,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
    * in clockwise order, which allows finding corners that can
    * be expanded.
    */
-  for (dir = NORTH; dir <= WEST; dir++)
+  for (dir = NORTH; dir <= WEST; directionIncrement(dir))
     {
       /* don't break the edge we came from */
       if (e->expand_dir != ((dir + 2) % 4))
@@ -2855,7 +2894,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
  * moveable as possible.
  */
   first = last = -1;
-  for (dir = NORTH; dir <= WEST; dir++)
+  for (dir = NORTH; dir <= WEST; directionIncrement(dir))
     {
       if (heap[dir] && !heap_is_empty (heap[dir]))
 	{
@@ -2895,7 +2934,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
 		      assert (0);
 		      break;
 		    }
-		  moveable_edge (edges, &db, dir + 3, rb, NULL, e, targets,
+		  moveable_edge (edges, &db, (direction_t)(dir + 3), rb, NULL, e, targets,
 				 s, NULL, NULL);
 		}
 	      else if (dir == NORTH)	/* north is start, so nothing "before" it */
@@ -2922,7 +2961,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
 	       * which it belongs to. 
 	       */
 	      BoxType db = previous_edge (last, dir, &rb->sbox);
-	      moveable_edge (edges, &db, dir - 1, rb, NULL, e, targets, s,
+	      moveable_edge (edges, &db, (direction_t)(dir - 1), rb, NULL, e, targets, s,
 			     NULL, NULL);
 	    }
 	  if (broke.is_valid_center && !blk->flags.source)
@@ -2954,7 +2993,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
 		}
 	      if (heap_is_empty (heap[dir]))
 		break;
-	      blk = heap_remove_smallest (heap[dir]);
+	      blk = (routebox_t *)heap_remove_smallest (heap[dir]);
 	      broke = break_box_edge (&b, dir, blk);
 	      if (broke.is_valid_left)
 		moveable_edge (edges, &broke.left, dir, rb, NULL, e, targets,
@@ -2986,7 +3025,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
 	    {
 	      /* expand the leftover from the prior direction */
 	      BoxType db = previous_edge (last, dir, &rb->sbox);
-	      moveable_edge (edges, &db, dir - 1, rb, NULL, e, targets, s,
+	      moveable_edge (edges, &db, (direction_t)(dir - 1), rb, NULL, e, targets, s,
 			     NULL, NULL);
 	    }
 	  last = -1;
@@ -3018,7 +3057,7 @@ BreakManyEdges (struct routeone_state * s, rtree_t * targets, rtree_t * tree,
 	}
     }
   /* done with all expansion edges of this box */
-  for (dir = NORTH; dir <= WEST; dir++)
+  for (dir = NORTH; dir <= WEST; directionIncrement(dir))
     {
       if (heap[dir])
 	heap_destroy (&heap[dir]);
@@ -3680,7 +3719,7 @@ CreateSearchEdge (struct routeone_state *s, vetting_t * work, edge_t * parent,
   if (cost < s->best_cost)
     {
       edge_t *ne;
-      ne = malloc (sizeof (*ne));
+      ne = (edge_t *)malloc (sizeof (*ne));
       memset ((void *) ne, 0, sizeof (*ne));
       assert (ne);
       ne->flags.via_search = 1;
@@ -3809,7 +3848,7 @@ do_via_search (edge_t * search, struct routeone_state *s,
       while (!vector_is_empty (v))
 	{
 	  BoxType cliparea;
-	  BoxType *area = vector_remove_last (v);
+	  BoxType *area = (BoxType *)vector_remove_last (v);
 	  if (!(i == NO_CONFLICT || AutoRouteParameters.with_conflicts))
 	    {
 	      free (area);
@@ -3827,7 +3866,7 @@ do_via_search (edge_t * search, struct routeone_state *s,
 	      if (j == within->group || !is_layer_group_active[j])
 		continue;
 	      ne = CreateViaEdge (&cliparea, j, within, search,
-				  within_conflict_level, i, targets);
+				  within_conflict_level, (conflict_t)i, targets);
 	      add_or_destroy_edge (s, ne);
 	    }
 	}
@@ -3965,9 +4004,9 @@ __conflict_source (const BoxType * box, void *cl)
     return 0;
   else
     {
-      routebox_t *this = (routebox_t *) cl;
-      path_conflicts (this, rb, false);
-      touch_conflicts (this->conflicts_with, 1);
+      routebox_t *dis = (routebox_t *) cl;
+      path_conflicts (dis, rb, false);
+      touch_conflicts (dis->conflicts_with, 1);
     }
   return 1;
 }
@@ -4080,7 +4119,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
   assert (!from->flags.target);
   assert (num_targets > 0);
   /* create list of target pointers and from that a r-tree of targets */
-  target_list = malloc (num_targets * sizeof (*target_list));
+  target_list = (const BoxType **)malloc (num_targets * sizeof (*target_list));
   i = 0;
   LIST_LOOP (from, same_net, p);
   if (p->flags.target)
@@ -4091,7 +4130,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
 #endif
     }
   END_LOOP;
-  targets = r_create_tree (target_list, i, 0);
+  targets = r_create_tree ((const BoxType **)target_list, i, 0);
   assert (i <= num_targets);
   free (target_list);
 
@@ -4139,7 +4178,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
   assert (s.workheap);
   while (!vector_is_empty (source_vec))
     {
-      edge_t *e = vector_remove_last (source_vec);
+      edge_t *e = (edge_t *)vector_remove_last (source_vec);
       assert (is_layer_group_active[e->rb->group]);
       e->cost = edge_cost (e, EXPENSIVE);
       heap_insert (s.workheap, e->cost, e);
@@ -4155,7 +4194,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
   vss.hi_conflict_space_vec = vector_create ();
   while (!heap_is_empty (s.workheap))
     {
-      edge_t *e = heap_remove_smallest (s.workheap);
+      edge_t *e = (edge_t *)heap_remove_smallest (s.workheap);
 #ifdef ROUTE_DEBUG
       if (aabort)
 	goto dontexpand;
@@ -4431,7 +4470,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
 			    area_vec, ans, nrb, e);
 	  while (!vector_is_empty (broken))
 	    {
-	      edge_t *ne = vector_remove_last (broken);
+	      edge_t *ne = (edge_t *)vector_remove_last (broken);
 	      add_or_destroy_edge (&s, ne);
 	    }
 	  vector_destroy (&broken);
@@ -4468,7 +4507,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
 	{
 	  while (!vector_is_empty (s.best_path->conflicts_with))
 	    {
-	      rb = vector_remove_last (s.best_path->conflicts_with);
+	      rb = (routebox_t *)vector_remove_last (s.best_path->conflicts_with);
 	      rb->flags.is_bad = 1;
 	      result.route_had_conflicts++;
 	    }
@@ -4506,7 +4545,7 @@ RouteOne (routedata_t * rd, routebox_t * from, routebox_t * to, int max_edges)
   /* now remove all expansion areas from the r-tree. */
   while (!vector_is_empty (area_vec))
     {
-      routebox_t *rb = vector_remove_last (area_vec);
+      routebox_t *rb = (routebox_t *)vector_remove_last (area_vec);
       assert (!rb->flags.homeless);
       if (rb->conflicts_with
 	  && rb->parent.expansion_area->conflicts_with != rb->conflicts_with)
diff --git a/src/change.c b/src/change.c
index 2545d84..cb53b47 100644
--- a/src/change.c
+++ b/src/change.c
@@ -2283,7 +2283,7 @@ QueryInputAndChangeObjectName (int Type, void *Ptr1, void *Ptr2, void *Ptr3)
   if (name)
     {
       /* NB: ChangeObjectName takes ownership of the passed memory */
-      char *old = ChangeObjectName (Type, Ptr1, Ptr2, Ptr3, name);
+      char *old = (char *)ChangeObjectName (Type, Ptr1, Ptr2, Ptr3, name);
       if (old != (char *) -1)
 	{
 	  AddObjectToChangeNameUndoList (Type, Ptr1, Ptr2, Ptr3, old);
diff --git a/src/create.c b/src/create.c
index 07de918..f942c40 100644
--- a/src/create.c
+++ b/src/create.c
@@ -93,7 +93,7 @@ CreateNewBuffer (void)
 {
   DataTypePtr data;
   data = (DataTypePtr) calloc (1, sizeof (DataType));
-  data->pcb = (void *) PCB;
+  data->pcb = (PCBTypePtr) PCB;
   return data;
 }
 
@@ -148,9 +148,9 @@ CreateNewPCB (bool SetDefaultNames)
   int i;
 
   /* allocate memory, switch all layers on and copy resources */
-  ptr = calloc (1, sizeof (PCBType));
+  ptr = (PCBTypePtr)calloc (1, sizeof (PCBType));
   ptr->Data = CreateNewBuffer ();
-  ptr->Data->pcb = (void *) ptr;
+  ptr->Data->pcb = (PCBTypePtr) ptr;
 
   ptr->ThermStyle = 4;
   ptr->IsleArea = 2.e8;
@@ -719,7 +719,7 @@ CreateNewArcInElement (ElementTypePtr Element,
   if (Element->ArcN >= Element->ArcMax)
     {
       Element->ArcMax += STEP_ELEMENTARC;
-      arc = realloc (arc, Element->ArcMax * sizeof (ArcType));
+      arc = (ArcTypePtr)realloc (arc, Element->ArcMax * sizeof (ArcType));
       Element->Arc = arc;
       memset (arc + Element->ArcN, 0, STEP_ELEMENTARC * sizeof (ArcType));
     }
@@ -765,7 +765,7 @@ CreateNewLineInElement (ElementTypePtr Element,
   if (Element->LineN >= Element->LineMax)
     {
       Element->LineMax += STEP_ELEMENTLINE;
-      line = realloc (line, Element->LineMax * sizeof (LineType));
+      line = (LineTypePtr)realloc (line, Element->LineMax * sizeof (LineType));
       Element->Line = line;
       memset (line + Element->LineN, 0, STEP_ELEMENTLINE * sizeof (LineType));
     }
@@ -932,7 +932,7 @@ CreateNewLineInSymbol (SymbolTypePtr Symbol,
   if (Symbol->LineN >= Symbol->LineMax)
     {
       Symbol->LineMax += STEP_SYMBOLLINE;
-      line = realloc (line, Symbol->LineMax * sizeof (LineType));
+      line = (LineTypePtr)realloc (line, Symbol->LineMax * sizeof (LineType));
       Symbol->Line = line;
       memset (line + Symbol->LineN, 0, STEP_SYMBOLLINE * sizeof (LineType));
     }
@@ -1019,7 +1019,7 @@ CreateNewAttribute (AttributeListTypePtr list, char *name, char *value)
   if (list->Number >= list->Max)
     {
       list->Max += 10;
-      list->List = realloc (list->List, list->Max * sizeof (AttributeType));
+      list->List = (AttributeType *)realloc (list->List, list->Max * sizeof (AttributeType));
     }
   list->List[list->Number].name = STRDUP (name);
   list->List[list->Number].value = STRDUP (value);
diff --git a/src/dbus-pcbmain.c b/src/dbus-pcbmain.c
index 83b2e97..07e68c0 100644
--- a/src/dbus-pcbmain.c
+++ b/src/dbus-pcbmain.c
@@ -74,7 +74,7 @@ static void
 io_watch_handler_dbus_freed (void *data)
 {
   IOWatchHandler *handler;
-  handler = data;
+  handler = (IOWatchHandler *)data;
 
   // Remove the watch registered with the HID
   gui->unwatch_file (handler->pcb_watch);
@@ -121,7 +121,7 @@ static void
 timeout_handler_dbus_freed (void *data)
 {
   TimeoutHandler *handler;
-  handler = data;
+  handler = (TimeoutHandler *)data;
 
   // Remove the timeout registered with the HID
   gui->stop_timer (handler->pcb_timer);
@@ -133,7 +133,7 @@ void
 timeout_handler_cb (hidval data)
 {
   TimeoutHandler *handler;
-  handler = data.ptr;
+  handler = (TimeoutHandler *)data.ptr;
 
   // Re-add the timeout, as PCB will remove the current one
   // Do this before calling to dbus, incase DBus removes the timeout.
@@ -152,6 +152,7 @@ watch_add (DBusWatch * dbus_watch, void *data)
   int fd;
   unsigned int pcb_condition;
   unsigned int dbus_flags;
+  hidval temp;
 
   // We won't create a watch until it becomes enabled.
   if (!dbus_watch_get_enabled (dbus_watch))
@@ -171,11 +172,11 @@ watch_add (DBusWatch * dbus_watch, void *data)
   fd = dbus_watch_get_fd (dbus_watch);
 #endif
 
-  handler = malloc (sizeof (IOWatchHandler));
+  handler = (IOWatchHandler *)malloc (sizeof (IOWatchHandler));
+  temp.ptr = (void *)handler;
   handler->dbus_watch = dbus_watch;
   handler->pcb_watch =
-    gui->watch_file (fd, pcb_condition, io_watch_handler_cb,
-		     (hidval) (void *) handler);
+    gui->watch_file (fd, pcb_condition, io_watch_handler_cb, temp);
 
   dbus_watch_set_data (dbus_watch, handler, io_watch_handler_dbus_freed);
   return TRUE;
@@ -203,6 +204,7 @@ static dbus_bool_t
 timeout_add (DBusTimeout * timeout, void *data)
 {
   TimeoutHandler *handler;
+  hidval temp;
 
   // We won't create a timeout until it becomes enabled.
   if (!dbus_timeout_get_enabled (timeout))
@@ -212,12 +214,12 @@ timeout_add (DBusTimeout * timeout, void *data)
   //       to manually re-add the timer each time it expires.
   //       This is non-ideal, and hopefully can be changed?
 
-  handler = malloc (sizeof (TimeoutHandler));
+  handler = (TimeoutHandler *)malloc (sizeof (TimeoutHandler));
+  temp.ptr = (void *)handler;
   handler->dbus_timeout = timeout;
   handler->interval = dbus_timeout_get_interval (timeout);
   handler->pcb_timer =
-    gui->add_timer (timeout_handler_cb, handler->interval,
-		    (hidval) (void *) handler);
+    gui->add_timer (timeout_handler_cb, handler->interval, temp);
 
   dbus_timeout_set_data (timeout, handler, timeout_handler_dbus_freed);
   return TRUE;
@@ -264,6 +266,7 @@ void
 pcb_dbus_connection_setup_with_mainloop (DBusConnection * connection)
 {
   //ConnectionSetup *cs;
+  hidval temp;
 
   /* FIXME we never free the slot, so its refcount just keeps growing,
    * which is kind of broken.
@@ -300,7 +303,8 @@ pcb_dbus_connection_setup_with_mainloop (DBusConnection * connection)
 //                                                cs, NULL);
 
   /* Register a new mainloop hook to mop up any unfinished IO. */
-  gui->add_block_hook (block_hook_cb, (hidval) (void *) connection);
+  temp.ptr = (void *)connection;
+  gui->add_block_hook (block_hook_cb, temp);
 
   return;
 nomem:
diff --git a/src/draw.c b/src/draw.c
index e0890da..bb212e9 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -1209,9 +1209,9 @@ DrawPinOrViaNameLowLevel (PinTypePtr Ptr)
   TextType text;
 
   if (!Ptr->Name || !Ptr->Name[0])
-    name = EMPTY (Ptr->Number);
+    name = (char *)EMPTY (Ptr->Number);
   else
-    name = EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? Ptr->Number : Ptr->Name);
+    name = (char *)EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? Ptr->Number : Ptr->Name);
 
   vert = TEST_FLAG (EDGE2FLAG, Ptr);
 
@@ -1425,9 +1425,9 @@ DrawPadNameLowLevel (PadTypePtr Pad)
   TextType text;
 
   if (!Pad->Name || !Pad->Name[0])
-    name = EMPTY (Pad->Number);
+    name = (char *)EMPTY (Pad->Number);
   else
-    name = EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? Pad->Number : Pad->Name);
+    name = (char *)EMPTY (TEST_FLAG (SHOWNUMBERFLAG, PCB) ? Pad->Number : Pad->Name);
 
   /* should text be vertical ? */
   vert = (Pad->Point1.X == Pad->Point2.X);
@@ -2292,7 +2292,7 @@ EraseObject (int type, void *lptr, void *ptr)
       break;
     case TEXT_TYPE:
     case ELEMENTNAME_TYPE:
-      EraseText (lptr, (TextTypePtr) ptr);
+      EraseText ((LayerTypePtr)lptr, (TextTypePtr) ptr);
       break;
     case POLYGON_TYPE:
       ErasePolygon ((PolygonTypePtr) ptr);
@@ -2396,7 +2396,7 @@ hid_expose_callback (HID * hid, BoxType * region, void *item)
   if (item)
     {
       doing_pinout = true;
-      DrawElement (item, 0);
+      DrawElement ((ElementTypePtr)item, 0);
       doing_pinout = false;
     }
   else
diff --git a/src/drill.c b/src/drill.c
index 1f1d770..a7a908b 100644
--- a/src/drill.c
+++ b/src/drill.c
@@ -126,7 +126,7 @@ GetDrillInfo (DataTypePtr top)
   bool DrillFound = false;
   bool NewDrill;
 
-  AllDrills = calloc (1, sizeof (DrillInfoType));
+  AllDrills = (DrillInfoTypePtr)calloc (1, sizeof (DrillInfoType));
   ALLPIN_LOOP (top);
   {
     if (!DrillFound)
@@ -235,7 +235,7 @@ RoundDrillInfo (DrillInfoTypePtr d, int roundto)
 	    = d->Drill[i].ElementN + d->Drill[i+1].ElementN;
 	  if (d->Drill[i].ElementMax)
 	    {
-	      d->Drill[i].Element = realloc (d->Drill[i].Element,
+	      d->Drill[i].Element = (ElementTypePtr *)realloc (d->Drill[i].Element,
 					     d->Drill[i].ElementMax *
 					     sizeof (ElementTypePtr));
 
@@ -253,7 +253,7 @@ RoundDrillInfo (DrillInfoTypePtr d, int roundto)
 	  d->Drill[i + 1].Element = NULL;
 
 	  d->Drill[i].PinMax = d->Drill[i].PinN + d->Drill[i + 1].PinN;
-	  d->Drill[i].Pin = realloc (d->Drill[i].Pin,
+	  d->Drill[i].Pin = (PinTypePtr *)realloc (d->Drill[i].Pin,
 				     d->Drill[i].PinMax *
 				     sizeof (PinTypePtr));
 	  memcpy (d->Drill[i].Pin + d->Drill[i].PinN, d->Drill[i + 1].Pin,
diff --git a/src/edif.y b/src/edif.y
index d9dbd8e..da33c9b 100644
--- a/src/edif.y
+++ b/src/edif.y
@@ -57,7 +57,7 @@ LibraryEntryTypePtr GetLibraryEntryMemory (LibraryMenuTypePtr);
 
  str_pair* new_str_pair(char* s1, char* s2)
  {
-     str_pair* ps = malloc(sizeof(str_pair));
+   str_pair* ps = (str_pair *)malloc(sizeof(str_pair));
      ps->str1 = s1;
      ps->str2 = s2;
      ps->next = NULL;
@@ -66,7 +66,7 @@ LibraryEntryTypePtr GetLibraryEntryMemory (LibraryMenuTypePtr);
  
  pair_list* new_pair_list(str_pair* ps)
  {
-     pair_list* pl = malloc(sizeof(pair_list));
+   pair_list* pl = (pair_list *)malloc(sizeof(pair_list));
      pl->list = ps;
      pl->name = NULL;
      return pl;
@@ -116,7 +116,7 @@ LibraryEntryTypePtr GetLibraryEntryMemory (LibraryMenuTypePtr);
      /* if renamed str2 also exists and must be freed */
      if ( name->str2 )  free(name->str2);
      free(name);
-     buf = malloc(256);
+     buf = (char *)malloc(256);
      if ( !buf )
      {
 	 /* no memory */
@@ -143,7 +143,7 @@ LibraryEntryTypePtr GetLibraryEntryMemory (LibraryMenuTypePtr);
 	 if ( tl + 3 > 256 )
 	 {
 	     free(buf);
-	     buf = malloc(tl+3);
+	     buf = (char *)malloc(tl+3);
 	     if ( !buf )
 	     {
 		 /* no memory */
@@ -2601,10 +2601,9 @@ Keyword :	EDIF_TOK_KEYWORD	{ $$=$1; }
  *
  *	  Garbage function for 'alloca()'.
  */
-char *xmalloc(siz)
-int siz;
+char *xmalloc(int siz)
 {
-  return (Malloc(siz));
+  return ((char *)Malloc(siz));
 }
 /*
  *	Token & context carriers:
@@ -3762,8 +3761,7 @@ static Keyword *KeywordTable[KEYWORD_HASH];
  *
  *	  The passed string is entered into the keyword hash table.
  */
-static void EnterKeyword(str)
-char *str;
+static void EnterKeyword(char * str)
 {
   /* 
    *	Locals.
@@ -3788,8 +3786,7 @@ char *str;
  *	is real useful for doing string comparisons by pointer value later.
  *	If there is no match, a NULL is returned.
  */
-static char *FindKeyword(str)
-char *str;
+static char *FindKeyword(char * str)
 {
   /*
    *	Locals.
@@ -3837,8 +3834,7 @@ static Token *TokenHash[TOKEN_HASH];
  *	  A pointer to the token of the passed code is returned. If
  *	no such beastie is present a NULL is returned instead.
  */
-static Token *FindToken(cod)
-register int cod;
+static Token *FindToken(register int cod)
 {
   /*
    *	Locals.
@@ -3871,8 +3867,7 @@ static Context *ContextHash[CONTEXT_HASH];
  *	  A pointer to the context of the passed code is returned. If
  *	no such beastie is present a NULL is returned instead.
  */
-static Context *FindContext(cod)
-register int cod;
+static Context *FindContext(register int cod)
 {
   /*
    *	Locals.
@@ -3909,16 +3904,14 @@ static short TokenType[TS_DEPTH];	/* token types */
  *	  Add a token to the debug stack. The passed string and type are
  *	what is to be pushed.
  */
-static Stack(str,typ)
-char *str;
-int typ;
+static Stack(char * str, int typ)
 {
   /*
    *	Free any previous string, then push.
    */
   if (TokenStack[TSP & TS_MASK])
     Free(TokenStack[TSP & TS_MASK]);
-  TokenStack[TSP & TS_MASK] = strcpy(Malloc(strlen(str) + 1),str);
+  TokenStack[TSP & TS_MASK] = strcpy((char *)Malloc(strlen(str) + 1),str);
   TokenType[TSP & TS_MASK] = typ;
   TSP += 1;
 }
@@ -4006,8 +3999,7 @@ static int StringSize = 0;		/* current string length */
  *
  *	  This adds the passed charater to the current string bucket.
  */
-static void PushString(chr)
-char chr;
+static void PushString(char chr)
 {
   /*
    *	Locals.
@@ -4178,8 +4170,7 @@ void ParseEDIF(char* filename,FILE* err)
  *	list to see if it is enabled. If so the token value is returned,
  *	if not then zero.
  */
-static int MatchToken(str)
-register char *str;
+static int MatchToken(register char * str)
 {
   /*
    *	Locals.
@@ -4207,8 +4198,7 @@ register char *str;
  *	  If the passed keyword string is within the current context, the
  *	new context is pushed and token value is returned. A zero otherwise.
  */
-static int MatchContext(str)
-register char *str;
+static int MatchContext(register char * str)
 {
   /*
    *	Locals.
@@ -4350,7 +4340,7 @@ static int yylex()
           break;
         Ungetc(c);
         yytext[--l] = '\0';
-        yylval.s = strcpy(Malloc(l + 1),yytext);
+        yylval.s = strcpy((char *)Malloc(l + 1),yytext);
         Stack(yytext,EDIF_TOK_INT);
         return (EDIF_TOK_INT);
       /*
@@ -4366,7 +4356,7 @@ static int yylex()
           Stack(yytext,c);
           return (c);
         }
-        yylval.s = strcpy(Malloc(l + 1),yytext);
+        yylval.s = strcpy((char *)Malloc(l + 1),yytext);
         Stack(yytext, EDIF_TOK_IDENT);
         return (EDIF_TOK_IDENT);
       /*
@@ -4398,7 +4388,7 @@ static int yylex()
           Stack(yytext,c);
           return (c);
         }
-        yylval.s = strcpy(Malloc(l + 1),yytext);
+        yylval.s = strcpy((char *)Malloc(l + 1),yytext);
         Stack(yytext, EDIF_TOK_KEYWORD);
         return (EDIF_TOK_KEYWORD);
       /*
diff --git a/src/file.c b/src/file.c
index 9e38217..1df23d5 100644
--- a/src/file.c
+++ b/src/file.c
@@ -440,7 +440,7 @@ PreLoadElementPCB ()
 
   yyFont = &yyPCB->Font;
   yyData = yyPCB->Data;
-  yyData->pcb = (void *)yyPCB;
+  yyData->pcb = yyPCB;
   yyData->LayerN = 0;
 }
 
@@ -556,7 +556,7 @@ WritePCBDataHeader (FILE * FP)
   fprintf (FP, "FileVersion[%i]\n", PCB_FILE_VERSION);
 
   fputs ("\nPCB[", FP);
-  PrintQuotedString (FP, EMPTY (PCB->Name));
+  PrintQuotedString (FP, (char *)EMPTY (PCB->Name));
   fprintf (FP, " %i %i]\n\n", (int) PCB->MaxWidth, (int) PCB->MaxHeight);
   fprintf (FP, "Grid[%s %i %i %i]\n",
 	   c_dtostr (PCB->Grid), (int) PCB->GridOffsetX,
@@ -639,7 +639,7 @@ WriteViaData (FILE * FP, DataTypePtr Data)
       fprintf (FP, "Via[%i %i %i %i %i %i ",
 	       via->X, via->Y,
 	       via->Thickness, via->Clearance, via->Mask, via->DrillingHole);
-      PrintQuotedString (FP, EMPTY (via->Name));
+      PrintQuotedString (FP, (char *)EMPTY (via->Name));
       fprintf (FP, " %s]\n", F2S (via, VIA_TYPE));
     }
 }
@@ -681,7 +681,7 @@ WritePCBNetlistData (FILE * FP)
 	  fprintf (FP, "\tNet(");
 	  PrintQuotedString(FP, &menu->Name[2]);
 	  fprintf (FP, " ");
-	  PrintQuotedString(FP, UNKNOWN (menu->Style));
+	  PrintQuotedString(FP, (char *)UNKNOWN (menu->Style));
 	  fprintf (FP, ")\n\t(\n");
 	  for (p = 0; p < menu->EntryN; p++)
 	    {
@@ -714,11 +714,11 @@ WriteElementData (FILE * FP, DataTypePtr Data)
        * both names of an element
        */
       fprintf (FP, "\nElement[%s ", F2S (element, ELEMENT_TYPE));
-      PrintQuotedString (FP, EMPTY (DESCRIPTION_NAME (element)));
+      PrintQuotedString (FP, (char *)EMPTY (DESCRIPTION_NAME (element)));
       fputc (' ', FP);
-      PrintQuotedString (FP, EMPTY (NAMEONPCB_NAME (element)));
+      PrintQuotedString (FP, (char *)EMPTY (NAMEONPCB_NAME (element)));
       fputc (' ', FP);
-      PrintQuotedString (FP, EMPTY (VALUE_NAME (element)));
+      PrintQuotedString (FP, (char *)EMPTY (VALUE_NAME (element)));
       fprintf (FP, " %i %i %i %i %i %i %s]\n(\n",
 	       (int) element->MarkX, (int) element->MarkY,
 	       (int) (DESCRIPTION_TEXT (element).X -
@@ -737,9 +737,9 @@ WriteElementData (FILE * FP, DataTypePtr Data)
 		   (int) (pin->Y - element->MarkY),
 		   (int) pin->Thickness, (int) pin->Clearance,
 		   (int) pin->Mask, (int) pin->DrillingHole);
-	  PrintQuotedString (FP, EMPTY (pin->Name));
+	  PrintQuotedString (FP, (char *)EMPTY (pin->Name));
 	  fprintf (FP, " ");
-	  PrintQuotedString (FP, EMPTY (pin->Number));
+	  PrintQuotedString (FP, (char *)EMPTY (pin->Number));
 	  fprintf (FP, " %s]\n", F2S (pin, PIN_TYPE));
 	}
       for (p = 0; p < element->PadN; p++)
@@ -752,9 +752,9 @@ WriteElementData (FILE * FP, DataTypePtr Data)
 		   (int) (pad->Point2.Y - element->MarkY),
 		   (int) pad->Thickness, (int) pad->Clearance,
 		   (int) pad->Mask);
-	  PrintQuotedString (FP, EMPTY (pad->Name));
+	  PrintQuotedString (FP, (char *)EMPTY (pad->Name));
 	  fprintf (FP, " ");
-	  PrintQuotedString (FP, EMPTY (pad->Number));
+	  PrintQuotedString (FP, (char *)EMPTY (pad->Number));
 	  fprintf (FP, " %s]\n", F2S (pad, PAD_TYPE));
 	}
       for (p = 0; p < element->LineN; p++)
@@ -798,7 +798,7 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
       (layer->Name && *layer->Name))
     {
       fprintf (FP, "Layer(%i ", (int) Number + 1);
-      PrintQuotedString (FP, EMPTY (layer->Name));
+      PrintQuotedString (FP, (char *)EMPTY (layer->Name));
       fputs (")\n(\n", FP);
       WriteAttributeList (FP, &layer->Attributes, "\t");
 
@@ -826,7 +826,7 @@ WriteLayerData (FILE * FP, Cardinal Number, LayerTypePtr layer)
 	  fprintf (FP, "\tText[%i %i %i %i ",
 		   (int) text->X, (int) text->Y,
 		   (int) text->Direction, (int) text->Scale);
-	  PrintQuotedString (FP, EMPTY (text->TextString));
+	  PrintQuotedString (FP, (char *)EMPTY (text->TextString));
 	  fprintf (FP, " %s]\n", F2S (text, TEXT_TYPE));
 	}
       for (n = 0; n < layer->PolygonN; n++)
@@ -1231,7 +1231,7 @@ LoadNewlibFootprintsFromDir(char *libpath, char *toppath)
 	 * entry->ListEntry points to fp name itself.
 	 */
 	len = strlen(subdir) + strlen("/") + strlen(subdirentry->d_name) + 1;
-	entry->AllocatedMemory = calloc (1, len);
+	entry->AllocatedMemory = (char *)calloc (1, len);
 	strcat (entry->AllocatedMemory, subdir);
 	strcat (entry->AllocatedMemory, PCB_DIR_SEPARATOR_S);
 
@@ -1455,7 +1455,7 @@ ReadLibraryContents (void)
 	  /* create the list entry */
 	  len = strlen (EMPTY (entry->Value)) +
 	    strlen (EMPTY (entry->Description)) + 4;
-	  entry->ListEntry = calloc (len, sizeof (char));
+	  entry->ListEntry = (char *)calloc (len, sizeof (char));
 	  sprintf (entry->ListEntry,
 		   "%s, %s", EMPTY (entry->Value),
 		   EMPTY (entry->Description));
diff --git a/src/find.c b/src/find.c
index 613629a..615659d 100644
--- a/src/find.c
+++ b/src/find.c
@@ -176,7 +176,7 @@ static DrcViolationType
                         long int *object_id_list,
                         int *object_type_list)
 {
-  DrcViolationType *violation = malloc (sizeof (DrcViolationType));
+  DrcViolationType *violation = (DrcViolationType *)malloc (sizeof (DrcViolationType));
 
   violation->title = strdup (title);
   violation->explanation = strdup (explanation);
@@ -614,7 +614,7 @@ InitComponentLookup (void)
   for (i = 0; i < 2; i++)
     {
       /* allocate memory for working list */
-      PadList[i].Data = calloc (NumberOfPads[i], sizeof (PadTypePtr));
+      PadList[i].Data = (void **)calloc (NumberOfPads[i], sizeof (PadTypePtr));
 
       /* clear some struct members */
       PadList[i].Location = 0;
@@ -641,12 +641,12 @@ InitLayoutLookup (void)
       if (layer->LineN)
         {
           /* allocate memory for line pointer lists */
-          LineList[i].Data = calloc (layer->LineN, sizeof (LineTypePtr));
+          LineList[i].Data = (void **)calloc (layer->LineN, sizeof (LineTypePtr));
           LineList[i].Size = layer->LineN;
         }
       if (layer->ArcN)
         {
-          ArcList[i].Data = calloc (layer->ArcN, sizeof (ArcTypePtr));
+          ArcList[i].Data = (void **)calloc (layer->ArcN, sizeof (ArcTypePtr));
           ArcList[i].Size = layer->ArcN;
         }
 
@@ -654,7 +654,7 @@ InitLayoutLookup (void)
       /* allocate memory for polygon list */
       if (layer->PolygonN)
         {
-          PolygonList[i].Data = calloc (layer->PolygonN, sizeof (PolygonTypePtr));
+          PolygonList[i].Data = (void **)calloc (layer->PolygonN, sizeof (PolygonTypePtr));
           PolygonList[i].Size = layer->PolygonN;
         }
 
@@ -679,13 +679,13 @@ InitLayoutLookup (void)
   else
     TotalV = 0;
   /* allocate memory for 'new PV to check' list and clear struct */
-  PVList.Data = calloc (TotalP + TotalV, sizeof (PinTypePtr));
+  PVList.Data = (void **)calloc (TotalP + TotalV, sizeof (PinTypePtr));
   PVList.Size = TotalP + TotalV;
   PVList.Location = 0;
   PVList.DrawLocation = 0;
   PVList.Number = 0;
   /* Initialize ratline data */
-  RatList.Data = calloc (PCB->Data->RatN, sizeof (RatTypePtr));
+  RatList.Data = (void **)calloc (PCB->Data->RatN, sizeof (RatTypePtr));
   RatList.Size = PCB->Data->RatN;
   RatList.Location = 0;
   RatList.DrawLocation = 0;
@@ -2771,9 +2771,9 @@ PrintElementNameList (ElementTypePtr Element, FILE * FP)
 {
   static DynamicStringType cname, pname, vname;
 
-  CreateQuotedString (&cname, EMPTY (DESCRIPTION_NAME (Element)));
-  CreateQuotedString (&pname, EMPTY (NAMEONPCB_NAME (Element)));
-  CreateQuotedString (&vname, EMPTY (VALUE_NAME (Element)));
+  CreateQuotedString (&cname, (char *)EMPTY (DESCRIPTION_NAME (Element)));
+  CreateQuotedString (&pname, (char *)EMPTY (NAMEONPCB_NAME (Element)));
+  CreateQuotedString (&vname, (char *)EMPTY (VALUE_NAME (Element)));
   fprintf (FP, "(%s %s %s)\n", cname.Data, pname.Data, vname.Data);
 }
 
@@ -2828,7 +2828,7 @@ PrintPadConnections (Cardinal Layer, FILE * FP, bool IsFirst)
     {
       ptr = PADLIST_ENTRY (Layer, 0);
       if (ptr != NULL)
-        PrintConnectionListEntry (UNKNOWN (ptr->Name), NULL, true, FP);
+        PrintConnectionListEntry ((char *)UNKNOWN (ptr->Name), NULL, true, FP);
       else
         printf ("Skipping NULL ptr in 1st part of PrintPadConnections\n");
     }
@@ -2840,7 +2840,7 @@ PrintPadConnections (Cardinal Layer, FILE * FP, bool IsFirst)
     {
       ptr = PADLIST_ENTRY (Layer, i);
       if (ptr != NULL)
-        PrintConnectionListEntry (EMPTY (ptr->Name), ptr->Element, false, FP);
+        PrintConnectionListEntry ((char *)EMPTY (ptr->Name), (ElementTypePtr)ptr->Element, false, FP);
       else
         printf ("Skipping NULL ptr in 2nd part of PrintPadConnections\n");
     }
@@ -2863,7 +2863,7 @@ PrintPinConnections (FILE * FP, bool IsFirst)
     {
       /* the starting pin */
       pv = PVLIST_ENTRY (0);
-      PrintConnectionListEntry (EMPTY (pv->Name), NULL, true, FP);
+      PrintConnectionListEntry ((char *)EMPTY (pv->Name), NULL, true, FP);
     }
 
   /* we maybe have to start with i=1 if we are handling the
@@ -2873,7 +2873,7 @@ PrintPinConnections (FILE * FP, bool IsFirst)
     {
       /* get the elements name or assume that its a via */
       pv = PVLIST_ENTRY (i);
-      PrintConnectionListEntry (EMPTY (pv->Name), pv->Element, false, FP);
+      PrintConnectionListEntry ((char *)EMPTY (pv->Name), (ElementTypePtr)pv->Element, false, FP);
     }
 }
 
@@ -2902,26 +2902,26 @@ ListsEmpty (bool AndRats)
 static bool
 DoIt (bool AndRats, bool AndDraw)
 {
-  bool new = false;
+  bool newone = false;
   do
     {
       /* lookup connections; these are the steps (2) to (4)
        * from the description
        */
-      new = LookupPVConnectionsToPVList ();
-      if (!new)
-        new = LookupLOConnectionsToPVList (AndRats);
-      if (!new)
-        new = LookupLOConnectionsToLOList (AndRats);
-      if (!new)
-        new = LookupPVConnectionsToLOList (AndRats);
+      newone = LookupPVConnectionsToPVList ();
+      if (!newone)
+        newone = LookupLOConnectionsToPVList (AndRats);
+      if (!newone)
+        newone = LookupLOConnectionsToLOList (AndRats);
+      if (!newone)
+        newone = LookupPVConnectionsToLOList (AndRats);
       if (AndDraw)
         DrawNewConnections ();
     }
-  while (!new && !ListsEmpty (AndRats));
+  while (!newone && !ListsEmpty (AndRats));
   if (AndDraw)
     Draw ();
-  return (new);
+  return (newone);
 }
 
 /* returns true if nothing un-found touches the passed line
@@ -2980,7 +2980,7 @@ PrintAndSelectUnusedPinsAndPadsOfElement (ElementTypePtr Element, FILE * FP)
                   }
 
                 /* write name to list and draw selected object */
-                CreateQuotedString (&oname, EMPTY (pin->Name));
+                CreateQuotedString (&oname, (char *)EMPTY (pin->Name));
                 fprintf (FP, "\t%s\n", oname.Data);
                 SET_FLAG (SELECTEDFLAG, pin);
                 DrawPin (pin, 0);
@@ -3024,7 +3024,7 @@ PrintAndSelectUnusedPinsAndPadsOfElement (ElementTypePtr Element, FILE * FP)
               }
 
             /* write name to list and draw selected object */
-            CreateQuotedString (&oname, EMPTY (pad->Name));
+            CreateQuotedString (&oname, (char *)EMPTY (pad->Name));
             fprintf (FP, "\t%s\n", oname.Data);
             SET_FLAG (SELECTEDFLAG, pad);
             DrawPad (pad, 0);
@@ -3089,7 +3089,7 @@ PrintElementConnections (ElementTypePtr Element, FILE * FP, bool AndDraw)
     /* pin might have been checked before, add to list if not */
     if (TEST_FLAG (TheFlag, pin))
       {
-        PrintConnectionListEntry (EMPTY (pin->Name), NULL, true, FP);
+        PrintConnectionListEntry ((char *)EMPTY (pin->Name), NULL, true, FP);
         fputs ("\t\t__CHECKED_BEFORE__\n\t}\n", FP);
         continue;
       }
@@ -3113,7 +3113,7 @@ PrintElementConnections (ElementTypePtr Element, FILE * FP, bool AndDraw)
     /* pad might have been checked before, add to list if not */
     if (TEST_FLAG (TheFlag, pad))
       {
-        PrintConnectionListEntry (EMPTY (pad->Name), NULL, true, FP);
+        PrintConnectionListEntry ((char *)EMPTY (pad->Name), NULL, true, FP);
         fputs ("\t\t__CHECKED_BEFORE__\n\t}\n", FP);
         continue;
       }
@@ -4339,13 +4339,13 @@ DRCAll (void)
             BuildObjectList (&object_count, &object_id_list, &object_type_list);
 
             title = _("Element %s has %i silk lines which are too thin");
-            name = UNKNOWN (NAMEONPCB_NAME (element));
+            name = (char *)UNKNOWN (NAMEONPCB_NAME (element));
 
             /* -4 is for the %s and %i place-holders */
             /* +11 is the max printed length for a 32 bit integer */
             /* +1 is for the \0 termination */
             buflen = strlen (title) - 4 + strlen (name) + 11 + 1;
-            buffer = malloc (buflen);
+            buffer = (char *)malloc (buflen);
             snprintf (buffer, buflen, title, name, tmpcnt);
 
             violation = pcb_drc_violation_new (buffer,
@@ -4478,8 +4478,8 @@ BuildObjectList (int *object_count, long int **object_id_list, int **object_type
     case ELEMENT_TYPE:
     case RATLINE_TYPE:
       *object_count = 1;
-      *object_id_list = malloc (sizeof (long int));
-      *object_type_list = malloc (sizeof (int));
+      *object_id_list = (long int *)malloc (sizeof (long int));
+      *object_type_list = (int *)malloc (sizeof (int));
       **object_id_list = ((AnyObjectType *)thing_ptr3)->ID;
       **object_type_list = thing_type;
       return;
diff --git a/src/free_atexit.c b/src/free_atexit.c
index 501775c..6527a46 100644
--- a/src/free_atexit.c
+++ b/src/free_atexit.c
@@ -48,7 +48,7 @@ void *leaky_malloc (size_t size)
 {
   void *new_memory = malloc(size + sizeof(leaky_admin_t));
 
-  free_list = realloc (free_list, (free_size + 1) * sizeof(void *));
+  free_list = (void **)realloc (free_list, (free_size + 1) * sizeof(void *));
   free_list[free_size] = new_memory;
   *(leaky_idx_t *)new_memory = free_size;
 
diff --git a/src/global.h b/src/global.h
index bb78abc..0420a18 100644
--- a/src/global.h
+++ b/src/global.h
@@ -153,7 +153,7 @@ typedef struct
 	BoxType		BoundingBox;	\
 	long int	ID;		\
 	FlagType	Flags;		\
-	struct LibraryEntryType *net
+	//	struct LibraryEntryType *net
 
 /* Lines, pads, and rats all use this so they can be cross-cast.  */
 #define	ANYLINEFIELDS			\
@@ -434,6 +434,7 @@ typedef struct
    *Value,			/* the value field */
    *Description;		/* some descritional text */
 } LibraryEntryType, *LibraryEntryTypePtr;
+//typedef LibraryEntryType *LibraryEntryTypePtr;
 
 /* If the internal flag is set, the only field that is valid is Name,
    and the struct is allocated with malloc instead of
diff --git a/src/heap.c b/src/heap.c
index fee6412..9e0f35e 100644
--- a/src/heap.c
+++ b/src/heap.c
@@ -120,7 +120,7 @@ heap_create ()
     MIN_COST = -1e23;
   assert (MIN_COST < 0);
   /* okay, create empty heap */
-  heap = calloc (1, sizeof (*heap));
+  heap = (heap_t *)calloc (1, sizeof (*heap));
   assert (heap);
   assert (__heap_is_good (heap));
   return heap;
@@ -179,7 +179,7 @@ heap_insert (heap_t * heap, cost_t cost, void *data)
       if (heap->max == 0)
 	heap->max = 256;		/* default initial heap size */
       heap->element =
-	realloc (heap->element, heap->max * sizeof (*heap->element));
+	(struct heap_element *)realloc (heap->element, heap->max * sizeof (*heap->element));
     }
   heap->size++;
   assert (heap->size < heap->max);
diff --git a/src/hid.h b/src/hid.h
index 94734ba..b13e75b 100644
--- a/src/hid.h
+++ b/src/hid.h
@@ -161,16 +161,18 @@ extern "C"
     double real_value;
   } HID_Attr_Val;
 
+  enum hids
+    { HID_Label, HID_Integer, HID_Real, HID_String,
+      HID_Boolean, HID_Enum, HID_Mixed, HID_Path
+    };
+
   typedef struct
   {
     char *name;
     /* If the help_text is this, usage() won't show this option */
 #define ATTR_UNDOCUMENTED ((char *)(1))
     char *help_text;
-    enum
-    { HID_Label, HID_Integer, HID_Real, HID_String,
-      HID_Boolean, HID_Enum, HID_Mixed, HID_Path
-    } type;
+    enum hids type;
     int min_val, max_val;	/* for integer and real */
     HID_Attr_Val default_val;	/* Also actual value for global attributes.  */
     const char **enumerations;
diff --git a/src/hid/bom/bom.c b/src/hid/bom/bom.c
index 04ad123..661b592 100644
--- a/src/hid/bom/bom.c
+++ b/src/hid/bom/bom.c
@@ -90,7 +90,7 @@ CleanBOMString (char *in)
   char *out;
   int i;
 
-  if ((out = malloc ((strlen (in) + 1) * sizeof (char))) == NULL)
+  if ((out = (char *)malloc ((strlen (in) + 1) * sizeof (char))) == NULL)
     {
       fprintf (stderr, "Error:  CleanBOMString() malloc() failed\n");
       exit (1);
@@ -144,25 +144,25 @@ xyToAngle (double x, double y)
 static StringList *
 string_insert (char *str, StringList * list)
 {
-  StringList *new, *cur;
+  StringList *newlist, *cur;
 
-  if ((new = (StringList *) malloc (sizeof (StringList))) == NULL)
+  if ((newlist = (StringList *) malloc (sizeof (StringList))) == NULL)
     {
       fprintf (stderr, "malloc() failed in string_insert()\n");
       exit (1);
     }
 
-  new->next = NULL;
-  new->str = strdup (str);
+  newlist->next = NULL;
+  newlist->str = strdup (str);
 
   if (list == NULL)
-    return (new);
+    return (newlist);
 
   cur = list;
   while (cur->next != NULL)
     cur = cur->next;
 
-  cur->next = new;
+  cur->next = newlist;
 
   return (list);
 }
@@ -170,23 +170,23 @@ string_insert (char *str, StringList * list)
 static BomList *
 bom_insert (char *refdes, char *descr, char *value, BomList * bom)
 {
-  BomList *new, *cur, *prev = NULL;
+  BomList *newlist, *cur, *prev = NULL;
 
   if (bom == NULL)
     {
       /* this is the first element so automatically create an entry */
-      if ((new = (BomList *) malloc (sizeof (BomList))) == NULL)
+      if ((newlist = (BomList *) malloc (sizeof (BomList))) == NULL)
 	{
 	  fprintf (stderr, "malloc() failed in bom_insert()\n");
 	  exit (1);
 	}
 
-      new->next = NULL;
-      new->descr = strdup (descr);
-      new->value = strdup (value);
-      new->num = 1;
-      new->refdes = string_insert (refdes, NULL);
-      return (new);
+      newlist->next = NULL;
+      newlist->descr = strdup (descr);
+      newlist->value = strdup (value);
+      newlist->num = 1;
+      newlist->refdes = string_insert (refdes, NULL);
+      return (newlist);
     }
 
   /* search and see if we already have used one of these
@@ -207,19 +207,19 @@ bom_insert (char *refdes, char *descr, char *value, BomList * bom)
 
   if (cur == NULL)
     {
-      if ((new = (BomList *) malloc (sizeof (BomList))) == NULL)
+      if ((newlist = (BomList *) malloc (sizeof (BomList))) == NULL)
 	{
 	  fprintf (stderr, "malloc() failed in bom_insert()\n");
 	  exit (1);
 	}
 
-      prev->next = new;
+      prev->next = newlist;
 
-      new->next = NULL;
-      new->descr = strdup (descr);
-      new->value = strdup (value);
-      new->num = 1;
-      new->refdes = string_insert (refdes, NULL);
+      newlist->next = NULL;
+      newlist->descr = strdup (descr);
+      newlist->value = strdup (value);
+      newlist->num = 1;
+      newlist->refdes = string_insert (refdes, NULL);
     }
 
   return (bom);
@@ -331,9 +331,9 @@ PrintBOM (void)
     found_pin2 = 0;
 
     /* insert this component into the bill of materials list */
-    bom = bom_insert (UNKNOWN (NAMEONPCB_NAME (element)),
-		      UNKNOWN (DESCRIPTION_NAME (element)),
-		      UNKNOWN (VALUE_NAME (element)), bom);
+    bom = bom_insert ((char *)UNKNOWN (NAMEONPCB_NAME (element)),
+		      (char *)UNKNOWN (DESCRIPTION_NAME (element)),
+		      (char *)UNKNOWN (VALUE_NAME (element)), bom);
 
 
     /*
@@ -446,9 +446,9 @@ PrintBOM (void)
 	       UNKNOWN (NAMEONPCB_NAME (element)), theta);
 	  }
 
-	name = CleanBOMString (UNKNOWN (NAMEONPCB_NAME (element)));
-	descr = CleanBOMString (UNKNOWN (DESCRIPTION_NAME (element)));
-	value = CleanBOMString (UNKNOWN (VALUE_NAME (element)));
+	name = CleanBOMString ((char *)UNKNOWN (NAMEONPCB_NAME (element)));
+	descr = CleanBOMString ((char *)UNKNOWN (DESCRIPTION_NAME (element)));
+	value = CleanBOMString ((char *)UNKNOWN (VALUE_NAME (element)));
 
  	y = PCB->MaxHeight - y;
  	if (xy_dim_type) {
diff --git a/src/hid/common/actions.c b/src/hid/common/actions.c
index d1e87f5..43c50f8 100644
--- a/src/hid/common/actions.c
+++ b/src/hid/common/actions.c
@@ -42,7 +42,7 @@ hid_register_actions (HID_Action * a, int n)
 {
   int i, count = 0;
   
-  all_actions = realloc (all_actions,
+  all_actions = (HID_Action **)realloc (all_actions,
                          (n_actions + n) * sizeof (HID_Action*));
   for (i = 0; i < n; i++)
     {
@@ -99,7 +99,7 @@ hid_find_action (const char *name)
   if (!all_actions_sorted)
     sort_actions ();
 
-  action = bsearch (name, all_actions, n_actions, sizeof (HID_Action*),
+  action = (HID_Action **)bsearch (name, all_actions, n_actions, sizeof (HID_Action*),
                     action_search_compar);
   if (action)
     return *action;
@@ -266,7 +266,7 @@ hid_parse_actionstring (const char *rstr, char require_parens)
   /*fprintf(stderr, "invoke: `%s'\n", rstr);*/
 
   sp = rstr;
-  str = malloc(strlen(rstr)+1);
+  str = (char *)malloc(strlen(rstr)+1);
 
 another:
   num = 0;
diff --git a/src/hid/common/draw_helpers.c b/src/hid/common/draw_helpers.c
index 1c7ead9..dc1f60f 100644
--- a/src/hid/common/draw_helpers.c
+++ b/src/hid/common/draw_helpers.c
@@ -8,8 +8,8 @@ static void fill_contour (hidGC gc, PLINE *pl)
   VNODE *v;
 
   n = pl->Count;
-  x = malloc (n * sizeof (int));
-  y = malloc (n * sizeof (int));
+  x = (int *)malloc (n * sizeof (int));
+  y = (int *)malloc (n * sizeof (int));
 
   for (v = &pl->head; i < n; v = v->next)
     {
@@ -63,7 +63,7 @@ static void thindraw_contour (hidGC gc, PLINE *pl)
 
 static void fill_contour_cb (PLINE *pl, void *user_data)
 {
-  hidGC gc = user_data;
+  hidGC gc = (hidGC)user_data;
   PLINE *local_pl = pl;
 
   fill_contour (gc, pl);
@@ -182,7 +182,7 @@ void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
 
 static int thindraw_hole_cb (PLINE *pl, void *user_data)
 {
-  hidGC gc = user_data;
+  hidGC gc = (hidGC)user_data;
   thindraw_contour (gc, pl);
   return 0;
 }
diff --git a/src/hid/common/extents.c b/src/hid/common/extents.c
index e8bd8ab..0f51b47 100644
--- a/src/hid/common/extents.c
+++ b/src/hid/common/extents.c
@@ -64,7 +64,7 @@ extents_set_layer (const char *name, int group, int empty)
 static hidGC
 extents_make_gc (void)
 {
-  hidGC rv = malloc (sizeof (hid_gc_struct));
+  hidGC rv = (hidGC)malloc (sizeof (hid_gc_struct));
   memset (rv, 0, sizeof (hid_gc_struct));
   return rv;
 }
@@ -97,7 +97,7 @@ extents_set_line_width (hidGC gc, int width)
 }
 
 static void
-extents_set_draw_xor (hidGC gc, int xor)
+extents_set_draw_xor (hidGC gc, int xor_)
 {
 }
 
diff --git a/src/hid/common/flags.c b/src/hid/common/flags.c
index 30859fb..9b53328 100644
--- a/src/hid/common/flags.c
+++ b/src/hid/common/flags.c
@@ -68,7 +68,7 @@ hid_find_flag (const char *name)
   if (all_flags == 0)
     {
       n = 0;
-      all_flags = malloc (n_flags * sizeof (HID_Flag));
+      all_flags = (HID_Flag *)malloc (n_flags * sizeof (HID_Flag));
       for (hf = hid_flag_nodes; hf; hf = hf->next)
 	for (i = 0; i < hf->n; i++)
 	  all_flags[n++] = hf->flags[i];
@@ -110,7 +110,7 @@ hid_get_flag (const char *name)
       if (nbuf < (cp - name + 1))
 	{
 	  nbuf = cp - name + 10;
-	  buf = realloc (buf, nbuf);
+	  buf = (char *)realloc (buf, nbuf);
 	}
       memcpy (buf, name, cp - name);
       buf[cp - name] = 0;
diff --git a/src/hid/common/hid_resource.c b/src/hid/common/hid_resource.c
index d5ba274..11f1171 100644
--- a/src/hid/common/hid_resource.c
+++ b/src/hid/common/hid_resource.c
@@ -86,8 +86,8 @@ load_mouse_resource (Resource *res)
 #endif
 
   button_count = res->c;
-  button_nums = malloc(res->c * sizeof(int));
-  mod_count = malloc(res->c * sizeof(int));
+  button_nums = (int *)malloc(res->c * sizeof(int));
+  mod_count = (int *)malloc(res->c * sizeof(int));
   action_count = 0;
   for (bi=0; bi<res->c; bi++)
     {
@@ -98,8 +98,8 @@ load_mouse_resource (Resource *res)
         action_count += res->v[bi].subres->c;
 
     }
-  mods = malloc(action_count * sizeof(int));
-  actions = malloc(action_count * sizeof(Resource*));
+  mods = (unsigned int *)malloc(action_count * sizeof(int));
+  actions = (Resource **)malloc(action_count * sizeof(Resource*));
 
   a = 0;
   for (bi=0; bi<res->c; bi++)
diff --git a/src/hid/common/hidinit.c b/src/hid/common/hidinit.c
index bb1a66b..9c4f8ee 100644
--- a/src/hid/common/hidinit.c
+++ b/src/hid/common/hidinit.c
@@ -655,9 +655,10 @@ hid_cache_color (int set, const char *name, hidval * val, void **vcache)
   ecache *e;
 
   cache = (ccache *) * vcache;
-  if (cache == 0)
-    cache = *vcache = (void *) calloc (sizeof (ccache), 1);
-
+  if (cache == 0) {
+    cache = (ccache *) calloc (sizeof (ccache), 1);
+    *vcache = cache;
+  }
   if (cache->lru && strcmp (cache->lru->name, name) == 0)
     {
       copy_color (set, &(cache->lru->val), val);
@@ -709,7 +710,7 @@ derive_default_filename(const char *pcbfile, HID_Attribute *filename_attrib, con
 
 	if (!pf || (memory && filename_attrib->default_val.str_value != *memory)) return;
 
-	buf = malloc (strlen (pf) + strlen(suffix) + 1);
+	buf = (char *)malloc (strlen (pf) + strlen(suffix) + 1);
 	if (memory) *memory = buf;
 	if (buf) {
 		size_t bl;
diff --git a/src/hid/common/hidnogui.c b/src/hid/common/hidnogui.c
index 08adb26..fd86b6a 100644
--- a/src/hid/common/hidnogui.c
+++ b/src/hid/common/hidnogui.c
@@ -104,7 +104,7 @@ nogui_set_line_width (hidGC gc, int width)
 }
 
 static void
-nogui_set_draw_xor (hidGC gc, int xor)
+nogui_set_draw_xor (hidGC gc, int xor_)
 {
   CRASH;
 }
diff --git a/src/hid/gcode/gcode.c b/src/hid/gcode/gcode.c
index f1bdcea..64d45cb 100644
--- a/src/hid/gcode/gcode.c
+++ b/src/hid/gcode/gcode.c
@@ -92,7 +92,7 @@ struct hid_gc_struct
 static struct color_struct *black = NULL, *white = NULL;
 static int linewidth = -1;
 static int lastgroup = -1;
-static gdImagePtr lastbrush = (void *) -1;
+static gdImagePtr lastbrush = (gdImagePtr)((void *) -1);
 static int lastcap = -1;
 static int lastcolor = -1;
 
@@ -198,7 +198,7 @@ gcode_get_png_name (const char *basename, const char *suffix)
   int len;
 
   len = strlen (basename) + strlen (suffix) + 6;
-  buf = malloc (sizeof (*buf) * len);
+  buf = (char *)malloc (sizeof (*buf) * len);
 
   sprintf (buf, "%s.%s.png", basename, suffix);
 
@@ -212,7 +212,7 @@ sort_drill (struct drill_struct *drill, int n_drill)
   int i, j, imin;
   double dmin, d;
   struct drill_struct p = { 0, 0 };
-  struct drill_struct *temp = malloc (n_drill * sizeof (struct drill_struct));
+  struct drill_struct *temp = (struct drill_struct *)malloc (n_drill * sizeof (struct drill_struct));
   for (j = 0; j < n_drill; j++)
     {
       dmin = 1e20;
@@ -368,7 +368,7 @@ gcode_start_png_export ()
   region.Y2 = PCB->MaxHeight;
 
   linewidth = -1;
-  lastbrush = (void *) -1;
+  lastbrush = (gdImagePtr)((void *) -1);
   lastcap = -1;
   lastgroup = -1;
   lastcolor = -1;
@@ -473,7 +473,7 @@ gcode_do_export (HID_Attr_Val * options)
 /* ***************** gcode conversion *************************** */
 /* potrace uses a different kind of bitmap; for simplicity gcode_im is copied to this format */
 	  bm = bm_new (gdImageSX (gcode_im), gdImageSY (gcode_im));
-	  filename = malloc (512);
+	  filename = (char *)malloc (512);
 	  plist = NULL;
 	  if (is_solder)
 	    {			/* only for back layer */
@@ -728,7 +728,7 @@ gcode_set_line_width (hidGC gc, int width)
 }
 
 static void
-gcode_set_draw_xor (hidGC gc, int xor)
+gcode_set_draw_xor (hidGC gc, int xor_)
 {
   ;
 }
@@ -794,7 +794,7 @@ use_gc (hidGC gc)
 
       if (hid_cache_color (0, name, &bval, &bcache))
 	{
-	  gc->brush = bval.ptr;
+	  gc->brush = (gdImagePtr)bval.ptr;
 	}
       else
 	{
diff --git a/src/hid/gerber/gerber.c b/src/hid/gerber/gerber.c
index 85e01f3..63344b3 100644
--- a/src/hid/gerber/gerber.c
+++ b/src/hid/gerber/gerber.c
@@ -39,8 +39,30 @@ RCSID ("$Id$");
 
 #define CRASH fprintf(stderr, "HID error: pcb called unimplemented Gerber function %s.\n", __FUNCTION__); abort()
 
-static HID gerber_hid;
+/*----------------------------------------------------------------------------*/
+/* Function prototypes                                                        */
+/*----------------------------------------------------------------------------*/
 
+static HID_Attribute * gerber_get_export_options (int *n);
+static void gerber_do_export (HID_Attr_Val * options);
+static void gerber_parse_arguments (int *argc, char ***argv);
+static int gerber_set_layer (const char *name, int group, int empty);
+static hidGC gerber_make_gc (void);
+static void gerber_destroy_gc (hidGC gc);
+static void gerber_use_mask (int use_it);
+static void gerber_set_color (hidGC gc, const char *name);
+static void gerber_set_line_cap (hidGC gc, EndCapStyle style);
+static void gerber_set_line_width (hidGC gc, int width);
+static void gerber_set_draw_xor (hidGC gc, int _xor);
+static void gerber_set_draw_faded (hidGC gc, int faded);
+static void gerber_set_line_cap_angle (hidGC gc, int x1, int y1, int x2, int y2);
+static void gerber_draw_line (hidGC gc, int x1, int y1, int x2, int y2);
+static void gerber_draw_arc (hidGC gc, int cx, int cy, int width, int height, int start_angle, int delta_angle);
+static void gerber_draw_rect (hidGC gc, int x1, int y1, int x2, int y2);
+static void gerber_fill_circle (hidGC gc, int cx, int cy, int radius);
+static void gerber_fill_rect (hidGC gc, int x1, int y1, int x2, int y2);
+static void gerber_calibrate (double xval, double yval);
+static void gerber_set_crosshair (int x, int y, int action);
 static void gerber_fill_polygon (hidGC gc, int n_coords, int *x, int *y);
 
 /*----------------------------------------------------------------------------*/
@@ -230,7 +252,7 @@ SetAppLayer (int l)
     {
       int prev = n_layerapps;
       n_layerapps = l + 1;
-      layerapps = realloc (layerapps, n_layerapps * sizeof (Apertures));
+      layerapps = (Apertures *)realloc (layerapps, n_layerapps * sizeof (Apertures));
       curapp = layerapps + prev;
       while (curapp < layerapps + n_layerapps)
 	{
@@ -246,6 +268,61 @@ SetAppLayer (int l)
 
 /* --------------------------------------------------------------------------- */
 
+static HID gerber_hid = {
+  sizeof (HID),
+  "gerber",
+  "RS-274X (Gerber) export.",
+  0, 0, 1, 0, 0, 1,
+  gerber_get_export_options,
+  gerber_do_export,
+  gerber_parse_arguments,
+  0 /* gerber_invalidate_lr */ ,
+  0 /* gerber_invalidate_all */ ,
+  gerber_set_layer,
+  gerber_make_gc,
+  gerber_destroy_gc,
+  gerber_use_mask,
+  gerber_set_color,
+  gerber_set_line_cap,
+  gerber_set_line_width,
+  gerber_set_draw_xor,
+  gerber_set_draw_faded,
+  gerber_set_line_cap_angle,
+  gerber_draw_line,
+  gerber_draw_arc,
+  gerber_draw_rect,
+  gerber_fill_circle,
+  gerber_fill_polygon,
+  common_fill_pcb_polygon,
+  0 /* gerber_thindraw_pcb_polygon */ ,
+  gerber_fill_rect,
+  gerber_calibrate,
+  0 /* gerber_shift_is_pressed */ ,
+  0 /* gerber_control_is_pressed */ ,
+  0 /* gerber_mod1_is_pressed */ ,
+  0 /* gerber_get_coords */ ,
+  gerber_set_crosshair,
+  0 /* gerber_add_timer */ ,
+  0 /* gerber_stop_timer */ ,
+  0 /* gerber_watch_file */ ,
+  0 /* gerber_unwatch_file */ ,
+  0 /* gerber_add_block_hook */ ,
+  0 /* gerber_stop_block_hook */ ,
+  0 /* gerber_log */ ,
+  0 /* gerber_logv */ ,
+  0 /* gerber_confirm_dialog */ ,
+  0 /* gerber_close_confirm_dialog */ ,
+  0 /* gerber_report_dialog */ ,
+  0 /* gerber_prompt_for */ ,
+  0 /* gerber_fileselect */ ,
+  0 /* gerber_attribute_dialog */ ,
+  0 /* gerber_show_item */ ,
+  0 /* gerber_beep */ ,
+  0 /* gerber_progress */ ,
+  0 /* gerber_drc_gui */
+};
+
+
 typedef struct hid_gc_struct
 {
   EndCapStyle cap;
@@ -362,7 +439,7 @@ gerber_do_export (HID_Attr_Val * options)
   all_layers = options[HA_all_layers].int_value;
 
   i = strlen (fnbase);
-  filename = realloc (filename, i + 40);
+  filename = (char *)realloc (filename, i + 40);
   strcpy (filename, fnbase);
   strcat (filename, ".");
   filesuff = filename + strlen (filename);
@@ -689,7 +766,7 @@ gerber_set_line_width (hidGC gc, int width)
 }
 
 static void
-gerber_set_draw_xor (hidGC gc, int xor)
+gerber_set_draw_xor (hidGC gc, int xor_)
 {
   ;
 }
@@ -744,7 +821,7 @@ use_gc (hidGC gc, int radius)
 	  c = SQUARE;
 	  break;
 	}
-      ap = findApertureCode (linewidth, c);
+      ap = findApertureCode (linewidth, (ApertureShape)c);
       if (ap <= 0)
 	{
 	  fprintf (stderr, "error: aperture for width %d type %s is %d\n",
@@ -1068,59 +1145,6 @@ gerber_set_crosshair (int x, int y, int action)
 {
 }
 
-static HID gerber_hid = {
-  sizeof (HID),
-  "gerber",
-  "RS-274X (Gerber) export.",
-  0, 0, 1, 0, 0, 1,
-  gerber_get_export_options,
-  gerber_do_export,
-  gerber_parse_arguments,
-  0 /* gerber_invalidate_lr */ ,
-  0 /* gerber_invalidate_all */ ,
-  gerber_set_layer,
-  gerber_make_gc,
-  gerber_destroy_gc,
-  gerber_use_mask,
-  gerber_set_color,
-  gerber_set_line_cap,
-  gerber_set_line_width,
-  gerber_set_draw_xor,
-  gerber_set_draw_faded,
-  gerber_set_line_cap_angle,
-  gerber_draw_line,
-  gerber_draw_arc,
-  gerber_draw_rect,
-  gerber_fill_circle,
-  gerber_fill_polygon,
-  common_fill_pcb_polygon,
-  0 /* gerber_thindraw_pcb_polygon */ ,
-  gerber_fill_rect,
-  gerber_calibrate,
-  0 /* gerber_shift_is_pressed */ ,
-  0 /* gerber_control_is_pressed */ ,
-  0 /* gerber_mod1_is_pressed */ ,
-  0 /* gerber_get_coords */ ,
-  gerber_set_crosshair,
-  0 /* gerber_add_timer */ ,
-  0 /* gerber_stop_timer */ ,
-  0 /* gerber_watch_file */ ,
-  0 /* gerber_unwatch_file */ ,
-  0 /* gerber_add_block_hook */ ,
-  0 /* gerber_stop_block_hook */ ,
-  0 /* gerber_log */ ,
-  0 /* gerber_logv */ ,
-  0 /* gerber_confirm_dialog */ ,
-  0 /* gerber_close_confirm_dialog */ ,
-  0 /* gerber_report_dialog */ ,
-  0 /* gerber_prompt_for */ ,
-  0 /* gerber_fileselect */ ,
-  0 /* gerber_attribute_dialog */ ,
-  0 /* gerber_show_item */ ,
-  0 /* gerber_beep */ ,
-  0 /* gerber_progress */ ,
-  0 /* gerber_drc_gui */
-};
 
 void
 hid_gerber_init ()
diff --git a/src/hid/gtk/gtkhid-gdk.c b/src/hid/gtk/gtkhid-gdk.c
index 0a2cc59..6ea9f9b 100644
--- a/src/hid/gtk/gtkhid-gdk.c
+++ b/src/hid/gtk/gtkhid-gdk.c
@@ -37,7 +37,7 @@ typedef struct hid_gc_struct
   gchar *colorname;
   gint width;
   gint cap, join;
-  gchar xor;
+  gchar xor_mask;
   gchar erase;
   gint mask_seq;
 }
@@ -117,7 +117,7 @@ ghid_draw_grid (void)
   if (n > npoints)
     {
       npoints = n + 10;
-      points = realloc (points, npoints * sizeof (GdkPoint));
+      points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint));
     }
   n = 0;
   for (x = x1; x <= x2; x += PCB->Grid)
@@ -346,7 +346,7 @@ ghid_set_color (hidGC gc, const char *name)
 	    gdk_color_white (gport->colormap, &cc->color);
 	  cc->color_set = 1;
 	}
-      if (gc->xor)
+      if (gc->xor_mask)
 	{
 	  if (!cc->xor_set)
 	    {
@@ -387,7 +387,7 @@ ghid_set_line_cap (hidGC gc, EndCapStyle style)
   if (gc->gc)
     gdk_gc_set_line_attributes (WHICH_GC (gc),
 				Vz (gc->width), GDK_LINE_SOLID,
-				gc->cap, gc->join);
+				(GdkCapStyle)gc->cap, (GdkJoinStyle)gc->join);
 }
 
 void
@@ -398,16 +398,16 @@ ghid_set_line_width (hidGC gc, int width)
   if (gc->gc)
     gdk_gc_set_line_attributes (WHICH_GC (gc),
 				Vz (gc->width), GDK_LINE_SOLID,
-				gc->cap, gc->join);
+				(GdkCapStyle)gc->cap, (GdkJoinStyle)gc->join);
 }
 
 void
-ghid_set_draw_xor (hidGC gc, int xor)
+ghid_set_draw_xor (hidGC gc, int xor_mask)
 {
-  gc->xor = xor;
+  gc->xor_mask = xor_mask;
   if (!gc->gc)
     return;
-  gdk_gc_set_function (gc->gc, xor ? GDK_XOR : GDK_COPY);
+  gdk_gc_set_function (gc->gc, xor_mask ? GDK_XOR : GDK_COPY);
   ghid_set_color (gc, gc->colorname);
 }
 
@@ -440,8 +440,8 @@ use_gc (hidGC gc)
       gc->gc = gdk_gc_new (gport->top_window->window);
       ghid_set_color (gc, gc->colorname);
       ghid_set_line_width (gc, gc->width);
-      ghid_set_line_cap (gc, gc->cap);
-      ghid_set_draw_xor (gc, gc->xor);
+      ghid_set_line_cap (gc, (EndCapStyle)gc->cap);
+      ghid_set_draw_xor (gc, gc->xor_mask);
     }
   if (gc->mask_seq != mask_seq)
     {
@@ -584,7 +584,7 @@ ghid_fill_polygon (hidGC gc, int n_coords, int *x, int *y)
   if (npoints < n_coords)
     {
       npoints = n_coords + 1;
-      points = realloc (points, npoints * sizeof (GdkPoint));
+      points = (GdkPoint *)realloc (points, npoints * sizeof (GdkPoint));
     }
   for (i = 0; i < n_coords; i++)
     {
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 8bbf3eb..169884e 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -488,7 +488,7 @@ ghid_set_crosshair (int x, int y, int action)
 
 typedef struct
 {
-  void (*func) ();
+  void (*func) (hidval);
   gint id;
   hidval user_data;
 }
@@ -584,7 +584,7 @@ ghid_watch_file (int fd, unsigned int condition, void (*func) (hidval watch, int
   watch->user_data = user_data;
   watch->fd = fd;
   watch->channel = g_io_channel_unix_new( fd );
-  watch->id = g_io_add_watch( watch->channel, glib_condition, ghid_watch, watch );
+  watch->id = g_io_add_watch( watch->channel, (GIOCondition)glib_condition, ghid_watch, watch );
 
   ret.ptr = (void *) watch;
   return ret;
@@ -691,8 +691,8 @@ ghid_confirm_dialog (char *msg, ...)
     }
 
   dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window),
-				   GTK_DIALOG_MODAL |
-				   GTK_DIALOG_DESTROY_WITH_PARENT,
+				   (GtkDialogFlags) (GTK_DIALOG_MODAL |
+						     GTK_DIALOG_DESTROY_WITH_PARENT),
 				   GTK_MESSAGE_QUESTION,
 				   GTK_BUTTONS_NONE,
 				   "%s", msg);
@@ -833,7 +833,7 @@ ghid_attributes_need_rows (int new_max)
       gtk_table_attach (GTK_TABLE (attr_table), attr_row[attr_max_rows].del,
 			0, 1,
 			attr_max_rows, attr_max_rows+1,
-			GTK_FILL | GTK_EXPAND,
+			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
 			GTK_FILL,
 			0, 0);
       g_signal_connect (G_OBJECT (attr_row[attr_max_rows].del), "clicked",
@@ -843,7 +843,7 @@ ghid_attributes_need_rows (int new_max)
       gtk_table_attach (GTK_TABLE (attr_table), attr_row[attr_max_rows].w_name,
 			1, 2,
 			attr_max_rows, attr_max_rows+1,
-			GTK_FILL | GTK_EXPAND,
+			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
 			GTK_FILL,
 			0, 0);
 
@@ -851,7 +851,7 @@ ghid_attributes_need_rows (int new_max)
       gtk_table_attach (GTK_TABLE (attr_table), attr_row[attr_max_rows].w_value,
 			2, 3,
 			attr_max_rows, attr_max_rows+1,
-			GTK_FILL | GTK_EXPAND,
+			(GtkAttachOptions)(GTK_FILL | GTK_EXPAND),
 			GTK_FILL,
 			0, 0);
 
@@ -1221,7 +1221,7 @@ Load (int argc, char **argv, int x, int y)
   if (argc > 1)
     return hid_actionv ("LoadFrom", argc, argv);
 
-  function = argc ? argv[0] : "Layout";
+  function = argc ? argv[0] : (char *)"Layout";
 
   if (strcasecmp (function, "Netlist") == 0)
     {
@@ -1293,7 +1293,7 @@ Save (int argc, char **argv, int x, int y)
   if (argc > 1)
     return hid_actionv ("SaveTo", argc, argv);
 
-  function = argc ? argv[0] : "Layout";
+  function = argc ? argv[0] : (char *)"Layout";
 
   if (strcasecmp (function, "Layout") == 0)
     if (PCB->Filename)
@@ -1825,7 +1825,7 @@ Open the DRC violations window.
 static int
 DoWindows (int argc, char **argv, int x, int y)
 {
-  char *a = argc == 1 ? argv[0] : "";
+  char *a = argc == 1 ? argv[0] : (char *)"";
 
   if (strcmp (a, "1") == 0 || strcasecmp (a, "Layout") == 0)
     {
diff --git a/src/hid/gtk/gui-command-window.c b/src/hid/gtk/gui-command-window.c
index b97ec0b..d865dee 100644
--- a/src/hid/gtk/gui-command-window.c
+++ b/src/hid/gtk/gui-command-window.c
@@ -464,7 +464,7 @@ ghid_handle_user_command (gboolean raise)
     {
       HideCrosshair (true);
       command = ghid_command_entry_get (_("Enter command:"),
-		      (Settings.SaveLastCommand && previous) ? previous : "");
+					(Settings.SaveLastCommand && previous) ? previous : (gchar *)"");
       if (command != NULL)
 	{
 	  /* copy new comand line to save buffer */
diff --git a/src/hid/gtk/gui-config.c b/src/hid/gtk/gui-config.c
index 36277eb..516feb5 100644
--- a/src/hid/gtk/gui-config.c
+++ b/src/hid/gtk/gui-config.c
@@ -417,7 +417,7 @@ set_config_attribute (gchar * option, gchar * arg)
       break;
 
     case CONFIG_String:
-      dup_string ((char **) ca->value, arg ? arg : "");
+      dup_string ((gchar **) ca->value, arg ? arg : (gchar *)"");
       break;
     default:
       break;
@@ -844,9 +844,9 @@ config_title_window_cb (GtkToggleButton * button, gpointer data)
 }
 
 static void
-config_general_toggle_cb (GtkToggleButton * button, gint * setting)
+config_general_toggle_cb (GtkToggleButton * button, void * setting)
 {
-  *setting = gtk_toggle_button_get_active (button);
+  *(gint *)setting = gtk_toggle_button_get_active (button);
   ghidgui->config_modified = TRUE;
 }
 
@@ -983,21 +983,21 @@ config_sizes_apply (void)
 }
 
 static void
-text_spin_button_cb (GtkSpinButton * spin, gint * dst)
+text_spin_button_cb (GtkSpinButton * spin, void * dst)
 {
-  *dst = gtk_spin_button_get_value_as_int (spin);
+  *(gint *)dst = gtk_spin_button_get_value_as_int (spin);
   ghidgui->config_modified = TRUE;
   ghid_set_status_line_label ();
 }
 
 
 static void
-size_spin_button_cb (GtkSpinButton * spin, gint * dst)
+size_spin_button_cb (GtkSpinButton * spin, void * dst)
 {
   gdouble value;
 
   value = gtk_spin_button_get_value (spin);
-  *dst = TO_PCB_UNITS (value);
+  *(gint *)dst = TO_PCB_UNITS (value);
   ghidgui->config_modified = TRUE;
 }
 
@@ -1151,12 +1151,12 @@ config_sizes_tab_create (GtkWidget * tab_vbox)
 static GtkWidget *config_increments_vbox, *config_increments_tab_vbox;
 
 static void
-increment_spin_button_cb (GtkSpinButton * spin, gdouble * dst)
+increment_spin_button_cb (GtkSpinButton * spin, void * dst)
 {
   gdouble value;
 
   value = gtk_spin_button_get_value (spin);
-  *dst = value;			/* Not using PCB units */
+  *(gdouble *)dst = value;			/* Not using PCB units */
 
 
   ghidgui->config_modified = TRUE;
@@ -1638,7 +1638,7 @@ ghid_config_groups_changed(void)
       else if (layer == solder_silk_layer)
 	name = _("solder side");
       else
-	name = UNKNOWN (PCB->Data->Layer[layer].Name);
+	name = (gchar *) UNKNOWN (PCB->Data->Layer[layer].Name);
 
       if (layer >= max_copper_layer)
 	{
@@ -1710,8 +1710,8 @@ config_layers_tab_create (GtkWidget * tab_vbox)
   button = gtk_button_new();
   arrow = gtk_arrow_new(GTK_ARROW_UP, GTK_SHADOW_ETCHED_IN);
   gtk_container_add(GTK_CONTAINER(button), arrow);
-  g_signal_connect(G_OBJECT(button), "clicked",
-		G_CALLBACK(edit_layer_button_cb), "c,up");
+  g_signal_connect(G_OBJECT(button), (gchar *)"clicked",
+		   G_CALLBACK(edit_layer_button_cb), (gchar *)"c,up");
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
@@ -1719,15 +1719,15 @@ config_layers_tab_create (GtkWidget * tab_vbox)
   button = gtk_button_new();
   arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_ETCHED_IN);
   gtk_container_add(GTK_CONTAINER(button), arrow);
-  g_signal_connect(G_OBJECT(button), "clicked",
-		G_CALLBACK(edit_layer_button_cb), "c,down");
+  g_signal_connect(G_OBJECT(button), (gchar *)"clicked",
+		   G_CALLBACK(edit_layer_button_cb), (gchar *)"c,down");
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
 
   button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
-  g_signal_connect(G_OBJECT(button), "clicked",
-		G_CALLBACK(edit_layer_button_cb), "c,-1");
+  g_signal_connect(G_OBJECT(button), (gchar *)"clicked",
+		   G_CALLBACK(edit_layer_button_cb), (gchar *)"c,-1");
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
@@ -1736,8 +1736,8 @@ config_layers_tab_create (GtkWidget * tab_vbox)
 			_("Add new layer above currently selected layer:"),
 			4, 2, TRUE, TRUE);
   button = gtk_button_new_from_stock(GTK_STOCK_ADD);
-  g_signal_connect(G_OBJECT(button), "clicked",
-		G_CALLBACK(edit_layer_button_cb), "-1,c");
+  g_signal_connect(G_OBJECT(button), (gchar *)"clicked",
+		   G_CALLBACK(edit_layer_button_cb), (gchar *)"-1,c");
   hbox = gtk_hbox_new(FALSE, 0);
   gtk_box_pack_start(GTK_BOX(vbox1), hbox, TRUE, TRUE, 0);
   gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
diff --git a/src/hid/gtk/gui-dialog-print.c b/src/hid/gtk/gui-dialog-print.c
index 0c50aed..9ced77b 100644
--- a/src/hid/gtk/gui-dialog-print.c
+++ b/src/hid/gtk/gui-dialog-print.c
@@ -47,26 +47,26 @@ RCSID ("$Id$");
 static GtkWidget *export_dialog = NULL;
 
 static void
-set_flag_cb (GtkToggleButton * button, gboolean * flag)
+set_flag_cb (GtkToggleButton * button, void * flag)
 {
-  *flag = gtk_toggle_button_get_active (button);
+  *(gboolean *)flag = gtk_toggle_button_get_active (button);
 }
 
 
 static void
-intspinner_changed_cb (GtkWidget * spin_button, gpointer data)
+intspinner_changed_cb (GtkSpinButton * spin_button, gpointer data)
 {
-  int *ival = data;
+  int *ival = (int *)data;
 
-  *ival = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin_button));
+  *ival = gtk_spin_button_get_value (GTK_SPIN_BUTTON ((GtkWidget *)spin_button));
 }
 
 static void
-dblspinner_changed_cb (GtkWidget * spin_button, gpointer data)
+dblspinner_changed_cb (GtkSpinButton * spin_button, gpointer data)
 {
-  double *dval = data;
+  double *dval = (double *)data;
 
-  *dval = gtk_spin_button_get_value (GTK_SPIN_BUTTON (spin_button));
+  *dval = gtk_spin_button_get_value (GTK_SPIN_BUTTON ((GtkWidget *)spin_button));
 }
 
 
@@ -110,8 +110,8 @@ ghid_attribute_dialog (HID_Attribute * attrs,
 
   dialog = gtk_dialog_new_with_buttons (_(title),
 					GTK_WINDOW (out->top_window),
-					GTK_DIALOG_MODAL
-					| GTK_DIALOG_DESTROY_WITH_PARENT,
+					(GtkDialogFlags)(GTK_DIALOG_MODAL
+							 | GTK_DIALOG_DESTROY_WITH_PARENT),
 					GTK_STOCK_CANCEL, GTK_RESPONSE_NONE,
 					GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
   gtk_window_set_wmclass (GTK_WINDOW (dialog), "PCB_attribute_editor", "PCB");
@@ -373,9 +373,9 @@ ghid_dialog_export (void)
 
   export_dialog = gtk_dialog_new_with_buttons (_("PCB Export Layout"),
 					       GTK_WINDOW (out->top_window),
-					       GTK_DIALOG_MODAL
+					       (GtkDialogFlags)(GTK_DIALOG_MODAL
 					       |
-					       GTK_DIALOG_DESTROY_WITH_PARENT,
+								GTK_DIALOG_DESTROY_WITH_PARENT),
 					       GTK_STOCK_CANCEL,
 					       GTK_RESPONSE_CANCEL, NULL);
   gtk_window_set_wmclass (GTK_WINDOW (export_dialog), "PCB_Export", "PCB");
diff --git a/src/hid/gtk/gui-dialog-size.c b/src/hid/gtk/gui-dialog-size.c
index 8409ba5..a5b5888 100644
--- a/src/hid/gtk/gui-dialog-size.c
+++ b/src/hid/gtk/gui-dialog-size.c
@@ -80,7 +80,7 @@ make_route_string(RouteStyleType * rs)
     {
       s = g_strdup_printf ("%s,%d,%d,%d,%d", rs->Name,
                rs->Thick, rs->Diameter, rs->Hole, rs->Keepaway);
-      colon = (i == NUM_STYLES - 1) ? NULL : ":";
+      colon = (i == NUM_STYLES - 1) ? NULL : (gchar *)":";
       t = str;
       str = g_strconcat (str, s, colon, NULL);
       g_free (t);
@@ -88,12 +88,43 @@ make_route_string(RouteStyleType * rs)
   return str;
 }
 
+/* static void */
+/* via_hole_cb (GtkWidget * widget, SizesDialog * sd) */
+/* { */
+/*   gdouble via_hole_size, via_size; */
+
+/*   via_hole_size = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)); */
+/*   via_size = */
+/*     gtk_spin_button_get_value (GTK_SPIN_BUTTON (sd->via_size_spin_button)); */
+
+/*   if (via_size < via_hole_size + FROM_PCB_UNITS (MIN_PINORVIACOPPER)) */
+/*     gtk_spin_button_set_value (GTK_SPIN_BUTTON (sd->via_size_spin_button), */
+/* 			       via_hole_size + */
+/* 			       FROM_PCB_UNITS (MIN_PINORVIACOPPER)); */
+/* } */
+
+/* static void */
+/* via_size_cb (GtkWidget * widget, SizesDialog * sd) */
+/* { */
+/*   gdouble via_hole_size, via_size; */
+
+/*   via_size = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)); */
+/*   via_hole_size = */
+/*     gtk_spin_button_get_value (GTK_SPIN_BUTTON (sd->via_hole_spin_button)); */
+
+/*   if (via_hole_size > via_size - FROM_PCB_UNITS (MIN_PINORVIACOPPER)) */
+/*     gtk_spin_button_set_value (GTK_SPIN_BUTTON (sd->via_hole_spin_button), */
+/* 			       via_size - */
+/* 			       FROM_PCB_UNITS (MIN_PINORVIACOPPER)); */
+/* } */
+
 static void
-via_hole_cb (GtkWidget * widget, SizesDialog * sd)
+via_hole_cb (GtkSpinButton * spinbutton, gpointer data)//SizesDialog * sd)
 {
+  SizesDialog * sd = (SizesDialog *)data;
   gdouble via_hole_size, via_size;
 
-  via_hole_size = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+  via_hole_size = gtk_spin_button_get_value (spinbutton);
   via_size =
     gtk_spin_button_get_value (GTK_SPIN_BUTTON (sd->via_size_spin_button));
 
@@ -104,11 +135,12 @@ via_hole_cb (GtkWidget * widget, SizesDialog * sd)
 }
 
 static void
-via_size_cb (GtkWidget * widget, SizesDialog * sd)
+via_size_cb (GtkSpinButton * spinbutton, gpointer data)//SizesDialog * sd)
 {
+  SizesDialog * sd = (SizesDialog *)data;
   gdouble via_hole_size, via_size;
 
-  via_size = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+  via_size = gtk_spin_button_get_value (spinbutton);
   via_hole_size =
     gtk_spin_button_get_value (GTK_SPIN_BUTTON (sd->via_hole_spin_button));
 
@@ -118,13 +150,29 @@ via_size_cb (GtkWidget * widget, SizesDialog * sd)
 			       FROM_PCB_UNITS (MIN_PINORVIACOPPER));
 }
 
+
+/* static void */
+/* use_temp_cb (GtkWidget * button, gpointer data) */
+/* { */
+/*   gint which = GPOINTER_TO_INT (data); */
+/*   gboolean active; */
+
+/*   active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); */
+/*   if (which == 1 && active) */
+/*     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON */
+/* 				  (route_sizes.set_temp2_button), FALSE); */
+/*   else if (which == 2 && active) */
+/*     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON */
+/* 				  (route_sizes.set_temp1_button), FALSE); */
+/* } */
+
 static void
-use_temp_cb (GtkWidget * button, gpointer data)
+use_temp_cb (GtkToggleButton * button, gpointer data)
 {
   gint which = GPOINTER_TO_INT (data);
   gboolean active;
 
-  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  active = gtk_toggle_button_get_active (button);
   if (which == 1 && active)
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
 				  (route_sizes.set_temp2_button), FALSE);
@@ -160,8 +208,8 @@ ghid_route_style_dialog (gint index, RouteStyleType * temp_rst)
   snprintf (buf, sizeof (buf), _("%s Sizes"), rst->Name);
   dialog = gtk_dialog_new_with_buttons (buf,
 					GTK_WINDOW (out->top_window),
-					GTK_DIALOG_MODAL |
-					GTK_DIALOG_DESTROY_WITH_PARENT,
+					(GtkDialogFlags)(GTK_DIALOG_MODAL |
+							 GTK_DIALOG_DESTROY_WITH_PARENT),
 					GTK_STOCK_CANCEL, GTK_RESPONSE_NONE,
 					GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
   gtk_window_set_wmclass (GTK_WINDOW (dialog), "Sizes_dialog", "PCB");
diff --git a/src/hid/gtk/gui-dialog.c b/src/hid/gtk/gui-dialog.c
index 80c1157..bb934bd 100644
--- a/src/hid/gtk/gui-dialog.c
+++ b/src/hid/gtk/gui-dialog.c
@@ -95,8 +95,8 @@ ghid_dialog_about (void)
   GtkWidget *dialog;
   GHidPort *out = &ghid_port;
   dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window),
-				   GTK_DIALOG_MODAL
-				   | GTK_DIALOG_DESTROY_WITH_PARENT,
+				   (GtkDialogFlags)(GTK_DIALOG_MODAL
+						    | GTK_DIALOG_DESTROY_WITH_PARENT),
 				   GTK_MESSAGE_INFO,
 				   GTK_BUTTONS_OK,
 				   "%s", GetInfoString ());
@@ -115,8 +115,8 @@ ghid_dialog_confirm_all (gchar * all_message)
 
   dialog = gtk_dialog_new_with_buttons ("Confirm",
 					GTK_WINDOW (out->top_window),
-					GTK_DIALOG_MODAL |
-					GTK_DIALOG_DESTROY_WITH_PARENT,
+					(GtkDialogFlags)(GTK_DIALOG_MODAL |
+							 GTK_DIALOG_DESTROY_WITH_PARENT),
 					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
 					GTK_STOCK_OK, GTK_RESPONSE_OK,
 					"Sequence OK",
@@ -142,8 +142,8 @@ ghid_dialog_message (gchar * message)
   GHidPort *out = &ghid_port;
 
   dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window),
-				   GTK_DIALOG_MODAL |
-				   GTK_DIALOG_DESTROY_WITH_PARENT,
+				   (GtkDialogFlags)(GTK_DIALOG_MODAL |
+						    GTK_DIALOG_DESTROY_WITH_PARENT),
 				   GTK_MESSAGE_WARNING, GTK_BUTTONS_OK,
 				   "%s", message);
 
@@ -170,8 +170,8 @@ ghid_dialog_confirm (gchar * message, gchar * cancelmsg, gchar * okmsg)
     }
 
   dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window),
-				   GTK_DIALOG_MODAL |
-				   GTK_DIALOG_DESTROY_WITH_PARENT,
+				   (GtkDialogFlags)(GTK_DIALOG_MODAL |
+						    GTK_DIALOG_DESTROY_WITH_PARENT),
 				   GTK_MESSAGE_QUESTION,
 				   GTK_BUTTONS_NONE,
 				   "%s", message);
@@ -218,8 +218,8 @@ ghid_dialog_close_confirm ()
   str = g_strconcat (str, "\n\n", tmp, NULL);
 
   dialog = gtk_message_dialog_new (GTK_WINDOW (out->top_window),
-                                   GTK_DIALOG_MODAL |
-                                     GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   (GtkDialogFlags)(GTK_DIALOG_MODAL |
+						    GTK_DIALOG_DESTROY_WITH_PARENT),
                                      GTK_MESSAGE_WARNING,
                                    GTK_BUTTONS_NONE, NULL);
   gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (dialog), str);
@@ -472,7 +472,7 @@ ghid_fileselect (const char *title, const char *descr,
 	{
 	  n_recent_dirs++;
 
-	  recent_dirs = realloc (recent_dirs, 
+	  recent_dirs = (ghid_file_history *)realloc (recent_dirs, 
 				  n_recent_dirs * sizeof (ghid_file_history));
 
 	  if (recent_dirs == NULL)
diff --git a/src/hid/gtk/gui-drc-window.c b/src/hid/gtk/gui-drc-window.c
index e2fa201..a708193 100644
--- a/src/hid/gtk/gui-drc-window.c
+++ b/src/hid/gtk/gui-drc-window.c
@@ -308,12 +308,12 @@ ghid_drc_violation_finalize (GObject * object)
   G_OBJECT_CLASS (ghid_drc_violation_parent_class)->finalize (object);
 }
 
-struct object_list
+typedef struct object_list
 {
   int count;
   long int *id_list;
   int *type_list;
-};
+} object_list;
 
 /*! \brief GObject property setter function
  *
@@ -332,7 +332,7 @@ ghid_drc_violation_set_property (GObject * object, guint property_id,
 				  const GValue * value, GParamSpec * pspec)
 {
   GhidDrcViolation *violation = GHID_DRC_VIOLATION (object);
-  struct object_list *obj_list;
+  object_list *obj_list;
 
   switch (property_id)
     {
@@ -373,7 +373,7 @@ ghid_drc_violation_set_property (GObject * object, guint property_id,
       /* Copy the passed data to make new lists */
       g_free (violation->object_id_list);
       g_free (violation->object_type_list);
-      obj_list = g_value_get_pointer (value);
+      obj_list = (object_list *)g_value_get_pointer (value);
       violation->object_count = obj_list->count;
       violation->object_id_list   = g_new (long int, obj_list->count);
       violation->object_type_list = g_new (int,      obj_list->count);
@@ -385,7 +385,7 @@ ghid_drc_violation_set_property (GObject * object, guint property_id,
     case PROP_PIXMAP:
       if (violation->pixmap)
 	g_object_unref (violation->pixmap);           /* Frees our old reference */
-      violation->pixmap = g_value_dup_object (value); /* Takes a new reference */
+      violation->pixmap = (GdkDrawable *)g_value_dup_object (value); /* Takes a new reference */
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -436,7 +436,7 @@ ghid_drc_violation_class_init (GhidViolationRendererClass * klass)
   gobject_class->set_property = ghid_drc_violation_set_property;
   gobject_class->get_property = ghid_drc_violation_get_property;
 
-  ghid_drc_violation_parent_class = g_type_class_peek_parent (klass);
+  ghid_drc_violation_parent_class = (GObjectClass *)g_type_class_peek_parent (klass);
 
   g_object_class_install_property (gobject_class, PROP_TITLE,
 				   g_param_spec_string ("title",
@@ -557,7 +557,7 @@ ghid_drc_violation_get_type ()
 
       ghid_drc_violation_type =
 	g_type_register_static (G_TYPE_OBJECT, "GhidDrcViolation",
-				&ghid_drc_violation_info, 0);
+				&ghid_drc_violation_info, (GTypeFlags)0);
     }
 
   return ghid_drc_violation_type;
@@ -567,13 +567,13 @@ ghid_drc_violation_get_type ()
 GhidDrcViolation *ghid_drc_violation_new (DrcViolationType *violation,
 					  GdkDrawable *pixmap)
 {
-  struct object_list obj_list;
+  object_list obj_list;
 
   obj_list.count = violation->object_count;
   obj_list.id_list = violation->object_id_list;
   obj_list.type_list = violation->object_type_list;
 
-  return g_object_new (GHID_TYPE_DRC_VIOLATION,
+  return (GhidDrcViolation *)g_object_new (GHID_TYPE_DRC_VIOLATION,
 		       "title",            violation->title,
 		       "explanation",      violation->explanation,
 		       "x-coord",          violation->x,
@@ -642,7 +642,7 @@ ghid_violation_renderer_set_property (GObject * object, guint property_id,
     case PROP_VIOLATION:
       if (renderer->violation != NULL)
 	g_object_unref (renderer->violation);
-      renderer->violation = g_value_dup_object (value);
+      renderer->violation = (GhidDrcViolation *)g_value_dup_object (value);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -807,7 +807,7 @@ ghid_violation_renderer_class_init (GhidViolationRendererClass * klass)
   cellrenderer_class->get_size = ghid_violation_renderer_get_size;
   cellrenderer_class->render = ghid_violation_renderer_render;
 
-  ghid_violation_renderer_parent_class = g_type_class_peek_parent (klass);
+  ghid_violation_renderer_parent_class = (GObjectClass *)g_type_class_peek_parent (klass);
 
   g_object_class_install_property (gobject_class, PROP_VIOLATION,
 				   g_param_spec_object ("violation",
@@ -848,7 +848,7 @@ ghid_violation_renderer_get_type ()
 
       ghid_violation_renderer_type =
 	g_type_register_static (GTK_TYPE_CELL_RENDERER_TEXT, "GhidViolationRenderer",
-				&ghid_violation_renderer_info, 0);
+				&ghid_violation_renderer_info, (GTypeFlags)0);
     }
 
   return ghid_violation_renderer_type;
@@ -867,7 +867,7 @@ ghid_violation_renderer_new (void)
 {
   GhidViolationRenderer *renderer;
 
-  renderer = g_object_new (GHID_TYPE_VIOLATION_RENDERER,
+  renderer = (GhidViolationRenderer *)g_object_new (GHID_TYPE_VIOLATION_RENDERER,
 			   "ypad", 6,
 			   NULL);
 
diff --git a/src/hid/gtk/gui-library-window.c b/src/hid/gtk/gui-library-window.c
index f54d914..eb366ba 100644
--- a/src/hid/gtk/gui-library-window.c
+++ b/src/hid/gtk/gui-library-window.c
@@ -154,7 +154,7 @@ ghid_library_window_create (GHidPort * out)
   if (library_window)
     return;
 
-  library_window = g_object_new (GHID_TYPE_LIBRARY_WINDOW, NULL);
+  library_window = (GtkWidget *)g_object_new (GHID_TYPE_LIBRARY_WINDOW, NULL);
 
   g_signal_connect (library_window,
                     "response",
@@ -782,7 +782,7 @@ library_window_constructor (GType type,
 					"xscale", 1.0,
 					"yscale", 1.0,
 					"xalign", 0.5, "yalign", 0.5, NULL));
-  preview = g_object_new (GHID_TYPE_PINOUT_PREVIEW,
+  preview = (GtkWidget *)g_object_new (GHID_TYPE_PINOUT_PREVIEW,
 			  /* GhidPinoutPreview */
 			  "element-data", NULL,
 			  /* GtkWidget */
@@ -831,7 +831,7 @@ library_window_class_init (GhidLibraryWindowClass * klass)
   gobject_class->constructor = library_window_constructor;
   gobject_class->finalize = library_window_finalize;
 
-  library_window_parent_class = g_type_class_peek_parent (klass);
+  library_window_parent_class = (GObjectClass *)g_type_class_peek_parent (klass);
 }
 
 
@@ -856,7 +856,7 @@ ghid_library_window_get_type ()
 
       library_window_type = g_type_register_static (GTK_TYPE_DIALOG,
 						    "GhidLibraryWindow",
-						    &library_window_info, 0);
+						    &library_window_info, (GTypeFlags)0);
     }
 
   return library_window_type;
diff --git a/src/hid/gtk/gui-log-window.c b/src/hid/gtk/gui-log-window.c
index ae25ed7..a91f346 100644
--- a/src/hid/gtk/gui-log-window.c
+++ b/src/hid/gtk/gui-log-window.c
@@ -208,7 +208,7 @@ be shown.";
 static gint
 GhidLogShowOnAppend (int argc, char **argv, int x, int y)
 {
-  char *a = argc == 1 ? argv[0] : "";
+  char *a = argc == 1 ? argv[0] : (char *)"";
 
   if (strncasecmp(a, "t", 1) == 0)
     {
diff --git a/src/hid/gtk/gui-misc.c b/src/hid/gtk/gui-misc.c
index e3316aa..1c55a99 100644
--- a/src/hid/gtk/gui-misc.c
+++ b/src/hid/gtk/gui-misc.c
@@ -91,10 +91,10 @@ ghid_size_increment_get_value (const gchar * saction, gchar ** value,
 
   increment = Settings.grid_units_mm
     ? Settings.size_increment_mm : Settings.size_increment_mil;
-  fmt = (*saction == '+') ? "+%f" : "-%f";
+  fmt = (*saction == '+') ? (gchar *)"+%f" : (gchar *)"-%f";
   snprintf (s_buf, sizeof (s_buf), fmt, increment);
   *value = s_buf;
-  *units = Settings.grid_units_mm ? "mm" : "mil";
+  *units = Settings.grid_units_mm ? (gchar *)"mm" : (gchar *)"mil";
 }
 
 void
@@ -107,10 +107,10 @@ ghid_line_increment_get_value (const gchar * saction, gchar ** value,
 
   increment = Settings.grid_units_mm
     ? Settings.line_increment_mm : Settings.line_increment_mil;
-  fmt = (*saction == '+') ? "+%f" : "-%f";
+  fmt = (*saction == '+') ? (gchar *)"+%f" : (gchar *)"-%f";
   snprintf (s_buf, sizeof (s_buf), fmt, increment);
   *value = s_buf;
-  *units = Settings.grid_units_mm ? "mm" : "mil";
+  *units = Settings.grid_units_mm ? (gchar *)"mm" : (gchar *)"mil";
 }
 
 void
@@ -123,10 +123,10 @@ ghid_clear_increment_get_value (const gchar * saction, gchar ** value,
 
   increment = Settings.grid_units_mm
     ? Settings.clear_increment_mm : Settings.clear_increment_mil;
-  fmt = (*saction == '+') ? "+%f" : "-%f";
+  fmt = (*saction == '+') ? (gchar *)"+%f" : (gchar *)"-%f";
   snprintf (s_buf, sizeof (s_buf), fmt, increment);
   *value = s_buf;
-  *units = Settings.grid_units_mm ? "mm" : "mil";
+  *units = Settings.grid_units_mm ? (gchar *)"mm" : (gchar *)"mil";
 }
 
 
@@ -138,7 +138,7 @@ gport_set_cursor (GdkCursorType shape)
   GdkColor bg = { 0, 0, 0, 0 };	/* black */
 
   if (!gport->drawing_area || !gport->drawing_area->window)
-    return 0;
+    return (GdkCursorType)0;
   if (gport->X_cursor_shape == shape)
     return shape;
 
@@ -200,7 +200,7 @@ ghid_mode_cursor (int Mode)
   switch (Mode)
     {
     case NO_MODE:
-      gport_set_cursor (CUSTOM_CURSOR_DRAG);
+      gport_set_cursor ((GdkCursorType)CUSTOM_CURSOR_DRAG);
       break;
 
     case VIA_MODE:
@@ -246,7 +246,7 @@ ghid_mode_cursor (int Mode)
 
     case ROTATE_MODE:
       if (ghid_shift_is_pressed ())
-	gport_set_cursor (CUSTOM_CURSOR_CLOCKWISE);
+	gport_set_cursor ((GdkCursorType)CUSTOM_CURSOR_CLOCKWISE);
       else
 	gport_set_cursor (GDK_EXCHANGE);
       break;
@@ -261,7 +261,7 @@ ghid_mode_cursor (int Mode)
       break;
 
     case LOCK_MODE:
-      gport_set_cursor (CUSTOM_CURSOR_LOCK);
+      gport_set_cursor ((GdkCursorType)CUSTOM_CURSOR_LOCK);
     }
 }
 
diff --git a/src/hid/gtk/gui-netlist-window.c b/src/hid/gtk/gui-netlist-window.c
index a5e38d1..b60b8ba 100644
--- a/src/hid/gtk/gui-netlist-window.c
+++ b/src/hid/gtk/gui-netlist-window.c
@@ -356,7 +356,7 @@ net_model_create (void)
         hash_string = g_strjoinv (NET_HIERARCHY_SEPARATOR, join_array);
         g_free (join_array);
 
-        row_ref = g_hash_table_lookup (prefix_hash, hash_string);
+        row_ref = (GtkTreeRowReference *)g_hash_table_lookup (prefix_hash, hash_string);
         g_free (hash_string);
 
         /* If we didn't find the path at this level, keep looping */
@@ -817,7 +817,7 @@ static gboolean
 hunt_named_node (GtkTreeModel *model, GtkTreePath *path,
                  GtkTreeIter *iter, gpointer data)
 {
-  struct ggnfnn_task *task = data;
+  struct ggnfnn_task *task = (struct ggnfnn_task *)data;
   LibraryMenuType *net;
   LibraryEntryType *node;
   gchar *str;
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index 2e820a3..349f91b 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -597,7 +597,7 @@ describe_location (LocationType X, LocationType Y)
     return NULL;
 
   if (type == PIN_TYPE || type == PAD_TYPE)
-    elename = UNKNOWN (NAMEONPCB_NAME ((ElementTypePtr) ptr1));
+    elename = (char *)UNKNOWN (NAMEONPCB_NAME ((ElementTypePtr) ptr1));
 
   pinname = ConnectionName (type, ptr1, ptr2);
 
diff --git a/src/hid/gtk/gui-pinout-preview.c b/src/hid/gtk/gui-pinout-preview.c
index 212d37a..fc69639 100644
--- a/src/hid/gtk/gui-pinout-preview.c
+++ b/src/hid/gtk/gui-pinout-preview.c
@@ -260,7 +260,7 @@ ghid_pinout_preview_set_property (GObject * object, guint property_id,
   switch (property_id)
     {
     case PROP_ELEMENT_DATA:
-      pinout_set_data (pinout, g_value_get_pointer (value));
+      pinout_set_data (pinout, (ElementType *)g_value_get_pointer (value));
       if (GTK_WIDGET_REALIZED (GTK_WIDGET (pinout)))
 	gdk_window_invalidate_rect (GTK_WIDGET (pinout)->window, NULL, FALSE);
       break;
@@ -316,7 +316,7 @@ ghid_pinout_preview_class_init (GhidPinoutPreviewClass * klass)
 
   gtk_widget_class->expose_event = ghid_pinout_preview_expose;
 
-  ghid_pinout_preview_parent_class = g_type_class_peek_parent (klass);
+  ghid_pinout_preview_parent_class = (GObjectClass *)g_type_class_peek_parent (klass);
 
   g_object_class_install_property (gobject_class, PROP_ELEMENT_DATA,
 				   g_param_spec_pointer ("element-data",
@@ -356,7 +356,7 @@ ghid_pinout_preview_get_type ()
 
       ghid_pinout_preview_type =
 	g_type_register_static (GTK_TYPE_DRAWING_AREA, "GhidPinoutPreview",
-				&ghid_pinout_preview_info, 0);
+				&ghid_pinout_preview_info, (GTypeFlags)0);
     }
 
   return ghid_pinout_preview_type;
@@ -375,7 +375,7 @@ ghid_pinout_preview_new (ElementType * element)
 {
   GhidPinoutPreview *pinout_preview;
 
-  pinout_preview = g_object_new (GHID_TYPE_PINOUT_PREVIEW,
+  pinout_preview = (GhidPinoutPreview *)g_object_new (GHID_TYPE_PINOUT_PREVIEW,
 				 "element-data", element, NULL);
 
   return GTK_WIDGET (pinout_preview);
diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index f2cdb99..4186d85 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -264,7 +264,7 @@ ghid_check_unique_accel (const char *accelerator)
   if (amax >= n_list) 
     {
       n_list += 128;
-      if ( (accel_list = realloc (accel_list, n_list * sizeof (char *))) == NULL)
+      if ( (accel_list = (char **)realloc (accel_list, n_list * sizeof (char *))) == NULL)
 	{
 	  fprintf (stderr, "%s():  realloc failed\n", __FUNCTION__);
 	  exit (1);
@@ -304,7 +304,7 @@ note_toggle_flag (const char *actionname, MenuFlagType type, char *name)
   if (n_tflags >= max_tflags)
     {
       max_tflags += 20;
-      tflags = realloc (tflags, max_tflags * sizeof (ToggleFlagType));
+      tflags = (ToggleFlagType *)realloc (tflags, max_tflags * sizeof (ToggleFlagType));
     }
   tflags[n_tflags].actionname = strdup (actionname);
   tflags[n_tflags].flagname = name;
@@ -1027,7 +1027,7 @@ layer_process (gchar **color_string, char **text, int *set, int i)
       break;
     default:		/* layers */
       *color_string = PCB->Data->Layer[i].Color;
-      *text = UNKNOWN (PCB->Data->Layer[i].Name);
+      *text = (char *)UNKNOWN (PCB->Data->Layer[i].Name);
       *set = PCB->Data->Layer[i].On;
       break;
     }
@@ -1638,7 +1638,7 @@ ghid_layer_enable_buttons_update (void)
   for (i = 0; i < max_copper_layer; ++i)
     {
       lb = &layer_buttons[i];
-      s = UNKNOWN (PCB->Data->Layer[i].Name);
+      s = (gchar *)UNKNOWN (PCB->Data->Layer[i].Name);
       if (dup_string (&lb->text, s))
 	{
 	  layer_enable_button_set_label (lb->label, _(s));
@@ -1646,15 +1646,15 @@ ghid_layer_enable_buttons_update (void)
 	}
       if (Settings.verbose)
 	{
-	  gboolean active, new;
+	  gboolean active, newone;
 
 	  active =
 	    gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON
 					  (lb->layer_enable_button));
-	  new = PCB->Data->Layer[i].On;
-	  if (active != new)
+	  newone = PCB->Data->Layer[i].On;
+	  if (active != newone)
 	    printf ("ghid_layer_enable_buttons_update: active=%d new=%d\n",
-		    active, new);
+		    active, newone);
 	}
       layer_process (&color_string, NULL, NULL, i);
       layer_button_set_color (lb, color_string, PCB->Data->Layer[i].On);
@@ -3010,7 +3010,7 @@ ghid_append_action (const char * name, const char *stock_id,
 
   accelerator = ghid_check_unique_accel (accelerator);
 
-  if ( (new_entries = realloc (new_entries, 
+  if ( (new_entries = (GtkActionEntry *)realloc (new_entries, 
 			       (menuitem_cnt + 1) * sizeof (GtkActionEntry))) == NULL)
     {
       fprintf (stderr, "ghid_append_action():  realloc of new_entries failed\n");
@@ -3018,7 +3018,7 @@ ghid_append_action (const char * name, const char *stock_id,
     }
   
 
-  if ( (action_resources = realloc (action_resources,
+  if ( (action_resources = (Resource **)realloc (action_resources,
 				    (menuitem_cnt + 1) * sizeof (Resource *))) == NULL)
     {
       fprintf (stderr, "ghid_append_action():  realloc of action_resources failed\n");
@@ -3047,7 +3047,7 @@ ghid_append_toggle_action (const char * name, const char *stock_id,
 
   accelerator = ghid_check_unique_accel (accelerator);
 
-  if ( (new_toggle_entries = realloc (new_toggle_entries, 
+  if ( (new_toggle_entries = (GtkToggleActionEntry *)realloc (new_toggle_entries, 
 				      (tmenuitem_cnt + 1) * sizeof (GtkToggleActionEntry))) == NULL)
     {
       fprintf (stderr, "ghid_append_toggle_action():  realloc of new_toggle_entries failed\n");
@@ -3055,7 +3055,7 @@ ghid_append_toggle_action (const char * name, const char *stock_id,
     }
   
 
-  if ( (toggle_action_resources = realloc (toggle_action_resources,
+  if ( (toggle_action_resources = (Resource **)realloc (toggle_action_resources,
 				    (tmenuitem_cnt + 1) * sizeof (Resource *))) == NULL)
     {
       fprintf (stderr, "ghid_append_toggle_action():  realloc of toggle_action_resources failed\n");
@@ -3693,23 +3693,23 @@ ghid_ui_info_indent (int indent)
  */
 
 static void
-ghid_ui_info_append (const gchar * new)
+ghid_ui_info_append (const gchar * newone)
 {
   gchar *p;
 
   if (new_ui_info_sz == 0) 
     {
       new_ui_info_sz = 1024;
-      new_ui_info = leaky_calloc (new_ui_info_sz, sizeof (gchar));
+      new_ui_info = (gchar *)leaky_calloc (new_ui_info_sz, sizeof (gchar));
     }
 
-  while (strlen (new_ui_info) + strlen (new) + 1 > new_ui_info_sz)
+  while (strlen (new_ui_info) + strlen (newone) + 1 > new_ui_info_sz)
     {
       size_t n;
       gchar * np;
 
       n = new_ui_info_sz + 1024;
-      if ((np = leaky_realloc (new_ui_info, n)) == NULL)
+      if ((np = (gchar *)leaky_realloc (new_ui_info, n)) == NULL)
 	{
 	  fprintf (stderr, "ghid_ui_info_append():  realloc of size %ld failed\n",
 		   (long int) n);
@@ -3720,11 +3720,11 @@ ghid_ui_info_append (const gchar * new)
     }
 
   p = new_ui_info + strlen (new_ui_info) ;
-  while (*new != '\0')
+  while (*newone != '\0')
     {
-      *p = *new;
+      *p = *newone;
       p++;
-      new++;
+      newone++;
     }
   
   *p = '\0';
diff --git a/src/hid/gtk/gui-utils.c b/src/hid/gtk/gui-utils.c
index 3d93d19..5db7b42 100644
--- a/src/hid/gtk/gui-utils.c
+++ b/src/hid/gtk/gui-utils.c
@@ -225,7 +225,7 @@ ghid_check_button_connected (GtkWidget * box,
 			     gboolean expand,
 			     gboolean fill,
 			     gint pad,
-			     void (*cb_func) (),
+			     void (*cb_func) (GtkToggleButton *, gpointer),
 			     gpointer data, gchar * string)
 {
   GtkWidget *b;
@@ -249,7 +249,7 @@ ghid_check_button_connected (GtkWidget * box,
 void
 ghid_button_connected (GtkWidget * box, GtkWidget ** button,
 		       gboolean pack_start, gboolean expand, gboolean fill,
-		       gint pad, void (*cb_func) (), gpointer data,
+		       gint pad, void (*cb_func) (gpointer), gpointer data,
 		       gchar * string)
 {
   GtkWidget *b;
@@ -273,7 +273,7 @@ void
 ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button, gfloat value,
 		  gfloat low, gfloat high, gfloat step0, gfloat step1,
 		  gint digits, gint width,
-		  void (*cb_func) (), gpointer data, gboolean right_align,
+		  void (*cb_func) (GtkSpinButton *, gpointer), gpointer data, gboolean right_align,
 		  gchar * string)
 {
   GtkWidget *hbox = NULL, *label, *spin_but;
@@ -323,7 +323,7 @@ ghid_table_spin_button (GtkWidget * table, gint row, gint column,
 			GtkWidget ** spin_button, gfloat value,
 			gfloat low, gfloat high, gfloat step0, gfloat step1,
 			gint digits, gint width,
-			void (*cb_func) (), gpointer data,
+			void (*cb_func) (GtkSpinButton *, gpointer), gpointer data,
 			gboolean right_align, gchar * string)
 {
   GtkWidget *label, *spin_but;
@@ -516,7 +516,7 @@ GtkTreeSelection *
 ghid_scrolled_selection (GtkTreeView * treeview, GtkWidget * box,
 			 GtkSelectionMode s_mode,
 			 GtkPolicyType h_policy, GtkPolicyType v_policy,
-			 void (*func_cb) (), gpointer data)
+			 void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data)
 {
   GtkTreeSelection *selection;
   GtkWidget *scrolled;
diff --git a/src/hid/gtk/gui.h b/src/hid/gtk/gui.h
index d2a76ce..df30955 100644
--- a/src/hid/gtk/gui.h
+++ b/src/hid/gtk/gui.h
@@ -365,7 +365,6 @@ gboolean dup_string (gchar ** dst, gchar * src);
 gboolean utf8_dup_string (gchar ** dst_utf8, gchar * src);
 void free_glist_and_data (GList ** list_head);
 
-
 ModifierKeysState ghid_modifier_keys_state (GdkModifierType * state);
 ButtonState ghid_button_state (GdkModifierType * state);
 gboolean ghid_is_modifier_key_sym (gint ksym);
@@ -382,23 +381,24 @@ gchar *ghid_entry_get_text (GtkWidget * entry);
 void ghid_check_button_connected (GtkWidget * box, GtkWidget ** button,
 				  gboolean active, gboolean pack_start,
 				  gboolean expand, gboolean fill, gint pad,
-				  void (*cb_func) (), gpointer data,
+				  void (*cb_func) (GtkToggleButton *, gpointer), gpointer data,
 				  gchar * string);
 void ghid_button_connected (GtkWidget * box, GtkWidget ** button,
 			    gboolean pack_start, gboolean expand,
-			    gboolean fill, gint pad, void (*cb_func) (),
+			    gboolean fill, gint pad, void (*cb_func) (gpointer),
 			    gpointer data, gchar * string);
 void ghid_spin_button (GtkWidget * box, GtkWidget ** spin_button,
 		       gfloat value, gfloat low, gfloat high, gfloat step0,
 		       gfloat step1, gint digits, gint width,
-		       void (*cb_func) (), gpointer data,
+		       void (*cb_func) (GtkSpinButton *, gpointer), gpointer data,
 		       gboolean right_align, gchar * string);
 void ghid_table_spin_button (GtkWidget * box, gint row, gint column,
 			     GtkWidget ** spin_button, gfloat value,
 			     gfloat low, gfloat high, gfloat step0,
 			     gfloat step1, gint digits, gint width,
-			     void (*cb_func) (), gpointer data,
+			     void (*cb_func) (GtkSpinButton *, gpointer), gpointer data,
 			     gboolean right_align, gchar * string);
+
 void ghid_range_control (GtkWidget * box, GtkWidget ** scale_res,
 			 gboolean horizontal, GtkPositionType pos,
 			 gboolean set_draw_value, gint digits,
@@ -435,7 +435,7 @@ GtkTreeSelection *ghid_scrolled_selection (GtkTreeView * treeview,
 					   GtkSelectionMode s_mode,
 					   GtkPolicyType h_policy,
 					   GtkPolicyType v_policy,
-					   void (*func_cb) (), gpointer data);
+					   void (*func_cb) (GtkTreeSelection *, gpointer), gpointer data);
 
 void ghid_dialog_report (gchar * title, gchar * message);
 void ghid_label_set_markup (GtkWidget * label, const gchar * text);
@@ -492,7 +492,7 @@ void ghid_use_mask (int use_it);
 void ghid_set_color (hidGC gc, const char *name);
 void ghid_set_line_cap (hidGC gc, EndCapStyle style);
 void ghid_set_line_width (hidGC gc, int width);
-void ghid_set_draw_xor (hidGC gc, int xor);
+void ghid_set_draw_xor (hidGC gc, int _xor);
 void ghid_set_draw_faded (hidGC gc, int faded);
 void ghid_set_line_cap_angle (hidGC gc, int x1, int y1, int x2, int y2);
 void ghid_draw_line (hidGC gc, int x1, int y1, int x2, int y2);
@@ -502,7 +502,7 @@ void ghid_draw_rect (hidGC gc, int x1, int y1, int x2, int y2);
 void ghid_fill_circle (hidGC gc, int cx, int cy, int radius);
 void ghid_fill_polygon (hidGC gc, int n_coords, int *x, int *y);
 void ghid_fill_rect (hidGC gc, int x1, int y1, int x2, int y2);
-void ghid_invalidate_lr ();
+void ghid_invalidate_lr (int left, int right, int top, int bottom);
 void ghid_invalidate_all ();
 void ghid_show_crosshair (gboolean show);
 
diff --git a/src/hid/nelma/nelma.c b/src/hid/nelma/nelma.c
index 5f6ebc7..60f5b37 100644
--- a/src/hid/nelma/nelma.c
+++ b/src/hid/nelma/nelma.c
@@ -109,7 +109,7 @@ struct hid_gc_struct {
 static struct color_struct *black = NULL, *white = NULL;
 static int      linewidth = -1;
 static int      lastgroup = -1;
-static gdImagePtr lastbrush = (void *) -1;
+static gdImagePtr lastbrush = (gdImagePtr)((void *) -1);
 static int      lastcap = -1;
 static int      lastcolor = -1;
 
@@ -197,7 +197,7 @@ nelma_get_png_name(const char *basename, const char *suffix)
 	int             len;
 
 	len = strlen(basename) + strlen(suffix) + 6;
-	buf = malloc(sizeof(*buf) * len);
+	buf = (char *)malloc(sizeof(*buf) * len);
 
 	sprintf(buf, "%s.%s.png", basename, suffix);
 
@@ -613,7 +613,7 @@ nelma_start_png_export()
 	region.Y2 = PCB->MaxHeight;
 
 	linewidth = -1;
-	lastbrush = (void *) -1;
+	lastbrush = (gdImagePtr)((void *) -1);
 	lastcap = -1;
 	lastgroup = -1;
 	lastcolor = -1;
@@ -676,7 +676,7 @@ nelma_do_export(HID_Attr_Val * options)
 	}
 
 	len = strlen(nelma_basename) + 4;
-	buf = malloc(sizeof(*buf) * len);
+	buf = (char *)malloc(sizeof(*buf) * len);
 
 	sprintf(buf, "%s.em", nelma_basename);
 	nelma_config = fopen(buf, "w");
@@ -793,7 +793,7 @@ nelma_set_line_width(hidGC gc, int width)
 }
 
 static void
-nelma_set_draw_xor(hidGC gc, int xor)
+nelma_set_draw_xor(hidGC gc, int xor_)
 {
 	;
 }
@@ -853,7 +853,7 @@ use_gc(hidGC gc)
 			gc->color->b, type, r);
 
 		if (hid_cache_color(0, name, &bval, &bcache)) {
-			gc->brush = bval.ptr;
+		  gc->brush = (gdImagePtr)bval.ptr;
 		} else {
 			int             bg, fg;
 			if (type == 'C')
diff --git a/src/hid/png/png.c b/src/hid/png/png.c
index 32639c8..06e22bb 100644
--- a/src/hid/png/png.c
+++ b/src/hid/png/png.c
@@ -105,7 +105,7 @@ static gdImagePtr im = NULL, master_im, mask_im = NULL;
 static FILE *f = 0;
 static int linewidth = -1;
 static int lastgroup = -1;
-static gdImagePtr lastbrush = (void *) -1;
+static gdImagePtr lastbrush = (gdImagePtr)((void *) -1);
 static int lastcap = -1;
 static int print_group[MAX_LAYER];
 static int print_layer[MAX_LAYER];
@@ -392,7 +392,7 @@ png_hid_export_to_file (FILE * the_file, HID_Attr_Val * options)
 	}
     }
   linewidth = -1;
-  lastbrush = (void *) -1;
+  lastbrush = (gdImagePtr)((void *) -1);
   lastcap = -1;
   lastgroup = -1;
   show_solder_side = Settings.ShowSolderSide;
@@ -1124,7 +1124,7 @@ png_set_color (hidGC gc, const char *name)
 
   if (hid_cache_color (0, name, &cval, &color_cache))
     {
-      gc->color = cval.ptr;
+      gc->color = (color_struct *)cval.ptr;
     }
   else if (name[0] == '#')
     {
@@ -1162,7 +1162,7 @@ png_set_line_width (hidGC gc, int width)
 }
 
 static void
-png_set_draw_xor (hidGC gc, int xor)
+png_set_draw_xor (hidGC gc, int xor_)
 {
   ;
 }
@@ -1235,7 +1235,7 @@ use_gc (hidGC gc)
 
       if (hid_cache_color (0, name, &bval, &brush_cache))
 	{
-	  gc->brush = bval.ptr;
+	  gc->brush = (gdImagePtr)bval.ptr;
 	}
       else
 	{
diff --git a/src/hid/ps/eps.c b/src/hid/ps/eps.c
index 83ce780..49a19c7 100644
--- a/src/hid/ps/eps.c
+++ b/src/hid/ps/eps.c
@@ -27,7 +27,86 @@
 RCSID ("$Id$");
 
 #define CRASH fprintf(stderr, "HID error: pcb called unimplemented EPS function %s.\n", __FUNCTION__); abort()
-static HID eps_hid;
+
+/*----------------------------------------------------------------------------*/
+/* Function prototypes                                                        */
+/*----------------------------------------------------------------------------*/
+static HID_Attribute * eps_get_export_options (int *n);
+static void eps_do_export (HID_Attr_Val * options);
+static void eps_parse_arguments (int *argc, char ***argv);
+static int eps_set_layer (const char *name, int group, int empty);
+static hidGC eps_make_gc (void);
+static void eps_destroy_gc (hidGC gc);
+static void eps_use_mask (int use_it);
+static void eps_set_color (hidGC gc, const char *name);
+static void eps_set_line_cap (hidGC gc, EndCapStyle style);
+static void eps_set_line_width (hidGC gc, int width);
+static void eps_set_draw_xor (hidGC gc, int _xor);
+static void eps_set_draw_faded (hidGC gc, int faded);
+static void eps_set_line_cap_angle (hidGC gc, int x1, int y1, int x2, int y2);
+static void eps_draw_rect (hidGC gc, int x1, int y1, int x2, int y2);
+static void eps_draw_line (hidGC gc, int x1, int y1, int x2, int y2);
+static void eps_draw_arc (hidGC gc, int cx, int cy, int width, int height, int start_angle, int delta_angle);
+static void eps_fill_rect (hidGC gc, int x1, int y1, int x2, int y2);
+static void eps_fill_circle (hidGC gc, int cx, int cy, int radius);
+static void eps_fill_polygon (hidGC gc, int n_coords, int *x, int *y);
+static void eps_calibrate (double xval, double yval);
+static void eps_set_crosshair (int x, int y, int action);
+/*----------------------------------------------------------------------------*/
+
+static HID eps_hid = {
+  sizeof (HID),
+  "eps",
+  "Encapsulated Postscript",
+  0, 0, 1, 0, 1, 0,
+  eps_get_export_options,
+  eps_do_export,
+  eps_parse_arguments,
+  0 /* eps_invalidate_lr */ ,
+  0 /* eps_invalidate_all */ ,
+  eps_set_layer,
+  eps_make_gc,
+  eps_destroy_gc,
+  eps_use_mask,
+  eps_set_color,
+  eps_set_line_cap,
+  eps_set_line_width,
+  eps_set_draw_xor,
+  eps_set_draw_faded,
+  eps_set_line_cap_angle,
+  eps_draw_line,
+  eps_draw_arc,
+  eps_draw_rect,
+  eps_fill_circle,
+  eps_fill_polygon,
+  common_fill_pcb_polygon,
+  0 /* eps_thindraw_pcb_polygon */ ,
+  eps_fill_rect,
+  eps_calibrate,
+  0 /* eps_shift_is_pressed */ ,
+  0 /* eps_control_is_pressed */ ,
+  0 /* eps_mod1_is_pressed */ ,
+  0 /* eps_get_coords */ ,
+  eps_set_crosshair,
+  0 /* eps_add_timer */ ,
+  0 /* eps_stop_timer */ ,
+  0 /* eps_watch_file */ ,
+  0 /* eps_unwatch_file */ ,
+  0 /* eps_add_block_hook */ ,
+  0 /* eps_stop_block_hook */ ,
+  0 /* eps_log */ ,
+  0 /* eps_logv */ ,
+  0 /* eps_confirm_dialog */ ,
+  0 /* eps_close_confirm_dialog */ ,
+  0 /* eps_report_dialog */ ,
+  0 /* eps_prompt_for */ ,
+  0 /* eps_attribute_dialog */ ,
+  0 /* eps_show_item */ ,
+  0 /* eps_beep */ ,
+  0 /* eps_progress */ ,
+  0 /* eps_drc_gui */ ,
+  0 /* eps_edit_attributes */
+};
 
 typedef struct hid_gc_struct
 {
@@ -454,7 +533,7 @@ eps_set_line_width (hidGC gc, int width)
 }
 
 static void
-eps_set_draw_xor (hidGC gc, int xor)
+eps_set_draw_xor (hidGC gc, int xor_)
 {
   ;
 }
@@ -610,59 +689,6 @@ eps_set_crosshair (int x, int y, int action)
 {
 }
 
-static HID eps_hid = {
-  sizeof (HID),
-  "eps",
-  "Encapsulated Postscript",
-  0, 0, 1, 0, 1, 0,
-  eps_get_export_options,
-  eps_do_export,
-  eps_parse_arguments,
-  0 /* eps_invalidate_lr */ ,
-  0 /* eps_invalidate_all */ ,
-  eps_set_layer,
-  eps_make_gc,
-  eps_destroy_gc,
-  eps_use_mask,
-  eps_set_color,
-  eps_set_line_cap,
-  eps_set_line_width,
-  eps_set_draw_xor,
-  eps_set_draw_faded,
-  eps_set_line_cap_angle,
-  eps_draw_line,
-  eps_draw_arc,
-  eps_draw_rect,
-  eps_fill_circle,
-  eps_fill_polygon,
-  common_fill_pcb_polygon,
-  0 /* eps_thindraw_pcb_polygon */ ,
-  eps_fill_rect,
-  eps_calibrate,
-  0 /* eps_shift_is_pressed */ ,
-  0 /* eps_control_is_pressed */ ,
-  0 /* eps_mod1_is_pressed */ ,
-  0 /* eps_get_coords */ ,
-  eps_set_crosshair,
-  0 /* eps_add_timer */ ,
-  0 /* eps_stop_timer */ ,
-  0 /* eps_watch_file */ ,
-  0 /* eps_unwatch_file */ ,
-  0 /* eps_add_block_hook */ ,
-  0 /* eps_stop_block_hook */ ,
-  0 /* eps_log */ ,
-  0 /* eps_logv */ ,
-  0 /* eps_confirm_dialog */ ,
-  0 /* eps_close_confirm_dialog */ ,
-  0 /* eps_report_dialog */ ,
-  0 /* eps_prompt_for */ ,
-  0 /* eps_attribute_dialog */ ,
-  0 /* eps_show_item */ ,
-  0 /* eps_beep */ ,
-  0 /* eps_progress */ ,
-  0 /* eps_drc_gui */ ,
-  0 /* eps_edit_attributes */
-};
 
 void
 hid_eps_init ()
diff --git a/src/hid/ps/ps.c b/src/hid/ps/ps.c
index eacf826..7c286cc 100644
--- a/src/hid/ps/ps.c
+++ b/src/hid/ps/ps.c
@@ -405,9 +405,9 @@ psopen (const char *base, const char *which)
   if (!multi_file)
     return fopen (base, "w");
 
-  buf = malloc (strlen (base) + strlen (which) + 5);
+  buf = (char *)malloc (strlen (base) + strlen (which) + 5);
 
-  suff = strrchr (base, '.');
+  suff = (char *)strrchr (base, '.');
   if (suff)
     {
       strcpy (buf, base);
@@ -930,7 +930,7 @@ ps_set_line_width (hidGC gc, int width)
 }
 
 static void
-ps_set_draw_xor (hidGC gc, int xor)
+ps_set_draw_xor (hidGC gc, int xor_)
 {
   ;
 }
diff --git a/src/insert.c b/src/insert.c
index 5e62463..7e9ebf2 100644
--- a/src/insert.c
+++ b/src/insert.c
@@ -97,27 +97,27 @@ static ObjectFunctionType InsertFunctions = {
 static void *
 InsertPointIntoRat (RatTypePtr Rat)
 {
-  LineTypePtr new;
+  LineTypePtr newone;
 
-  new = CreateDrawnLineOnLayer (CURRENT, Rat->Point1.X, Rat->Point1.Y,
+  newone = CreateDrawnLineOnLayer (CURRENT, Rat->Point1.X, Rat->Point1.Y,
 				InsertX, InsertY, Settings.LineThickness,
 				2 * Settings.Keepaway, Rat->Flags);
-  if (!new)
-    return new;
-  AddObjectToCreateUndoList (LINE_TYPE, CURRENT, new, new);
+  if (!newone)
+    return newone;
+  AddObjectToCreateUndoList (LINE_TYPE, CURRENT, newone, newone);
   EraseRat (Rat);
-  DrawLine (CURRENT, new, 0);
-  new = CreateDrawnLineOnLayer (CURRENT, Rat->Point2.X, Rat->Point2.Y,
+  DrawLine (CURRENT, newone, 0);
+  newone = CreateDrawnLineOnLayer (CURRENT, Rat->Point2.X, Rat->Point2.Y,
 				InsertX, InsertY, Settings.LineThickness,
 				2 * Settings.Keepaway, Rat->Flags);
-  if (new)
+  if (newone)
     {
-      AddObjectToCreateUndoList (LINE_TYPE, CURRENT, new, new);
-      DrawLine (CURRENT, new, 0);
+      AddObjectToCreateUndoList (LINE_TYPE, CURRENT, newone, newone);
+      DrawLine (CURRENT, newone, 0);
     }
   MoveObjectToRemoveUndoList (RATLINE_TYPE, Rat, Rat, Rat);
   Draw ();
-  return (new);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
diff --git a/src/intersect.c b/src/intersect.c
index 7389ba9..e7612e9 100644
--- a/src/intersect.c
+++ b/src/intersect.c
@@ -97,7 +97,7 @@ createSortedYList (BoxListTypePtr boxlist)
   int i, n;
   /* create sorted list of Y coordinates */
   yCoords.size = 2 * boxlist->BoxN;
-  yCoords.p = calloc (yCoords.size, sizeof (*yCoords.p));
+  yCoords.p = (LocationType *)calloc (yCoords.size, sizeof (*yCoords.p));
   for (i = 0; i < boxlist->BoxN; i++)
     {
       yCoords.p[2 * i] = boxlist->Box[i].Y1;
@@ -123,7 +123,7 @@ createSegmentTree (LocationType * yCoords, int N)
   int i;
   /* size is twice the nearest larger power of 2 */
   st.size = 2 * nextpwrof2 (N);
-  st.nodes = calloc (st.size, sizeof (*st.nodes));
+  st.nodes = (SegmentTreeNode *)calloc (st.size, sizeof (*st.nodes));
   /* initialize the rightmost leaf node */
   st.nodes[st.size - 1].left = (N > 0) ? yCoords[--N] : 10;
   st.nodes[st.size - 1].right = st.nodes[st.size - 1].left + 1;
@@ -234,8 +234,8 @@ ComputeUnionArea (BoxListTypePtr boxlist)
   segtree = createSegmentTree (yCoords.p, yCoords.size);
   free (yCoords.p);
   /* create sorted list of left and right X coordinates of rectangles */
-  rectLeft = calloc (boxlist->BoxN, sizeof (*rectLeft));
-  rectRight = calloc (boxlist->BoxN, sizeof (*rectRight));
+  rectLeft = (BoxTypePtr *)calloc (boxlist->BoxN, sizeof (*rectLeft));
+  rectRight = (BoxTypePtr *)calloc (boxlist->BoxN, sizeof (*rectRight));
   for (i = 0; i < boxlist->BoxN; i++)
     {
       assert (boxlist->Box[i].X1 <= boxlist->Box[i].X2);
diff --git a/src/main.c b/src/main.c
index 735fde7..3fff933 100644
--- a/src/main.c
+++ b/src/main.c
@@ -227,7 +227,7 @@ usage_hid (HID * h)
       exporter = NULL;
     }
 
-  note = malloc (sizeof (UsageNotes));
+  note = (UsageNotes *)malloc (sizeof (UsageNotes));
   note->next = usage_notes;
   note->seen = attributes;
   usage_notes = note;
@@ -721,7 +721,7 @@ InitPaths (char *argv0)
 #ifdef DEBUG
 	      printf ("Looking for %s in %s\n", argv0, p);
 #endif
-	      if ( (tmps = malloc ( (strlen (argv0) + strlen (p) + 2) * sizeof (char))) == NULL )
+	      if ( (tmps = (char *)malloc ( (strlen (argv0) + strlen (p) + 2) * sizeof (char))) == NULL )
 		{
 		  fprintf (stderr, "InitPaths():  malloc failed\n");
 		  exit (1);
diff --git a/src/misc.c b/src/misc.c
index e1e14c8..13c7398 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1002,13 +1002,13 @@ ExpandFilename (char *Dirname, char *Filename)
   DSClearString (&answer);
   if (Dirname)
     {
-      command = calloc (strlen (Filename) + strlen (Dirname) + 7,
+      command = (char *)calloc (strlen (Filename) + strlen (Dirname) + 7,
                         sizeof (char));
       sprintf (command, "echo %s/%s", Dirname, Filename);
     }
   else
     {
-      command = calloc (strlen (Filename) + 6, sizeof (char));
+      command = (char *)calloc (strlen (Filename) + 6, sizeof (char));
       sprintf (command, "echo %s", Filename);
     }
 
@@ -1904,7 +1904,7 @@ pcb_author (void)
             len = comma - gecos;
           else
             len = strlen (gecos);
-          fab_author = malloc (len + 1);
+          fab_author = (char *)malloc (len + 1);
           if (!fab_author)
             {
               perror ("pcb: out of memory.\n");
diff --git a/src/move.c b/src/move.c
index cbb2e3d..5e3913c 100644
--- a/src/move.c
+++ b/src/move.c
@@ -439,19 +439,19 @@ void *
 MoveLineToLayerLowLevel (LayerTypePtr Source, LineTypePtr Line,
 			 LayerTypePtr Destination)
 {
-  LineTypePtr new = GetLineMemory (Destination);
+  LineTypePtr newone = GetLineMemory (Destination);
 
   r_delete_entry (Source->line_tree, (BoxTypePtr) Line);
   /* copy the data and remove it from the former layer */
-  *new = *Line;
+  *newone = *Line;
   *Line = Source->Line[--Source->LineN];
   r_substitute (Source->line_tree, (BoxType *) & Source->Line[Source->LineN],
 		(BoxType *) Line);
   memset (&Source->Line[Source->LineN], 0, sizeof (LineType));
   if (!Destination->line_tree)
     Destination->line_tree = r_create_tree (NULL, 0, 0);
-  r_insert_entry (Destination->line_tree, (BoxTypePtr) new, 0);
-  return (new);
+  r_insert_entry (Destination->line_tree, (BoxTypePtr) newone, 0);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
@@ -461,19 +461,19 @@ void *
 MoveArcToLayerLowLevel (LayerTypePtr Source, ArcTypePtr Arc,
 			LayerTypePtr Destination)
 {
-  ArcTypePtr new = GetArcMemory (Destination);
+  ArcTypePtr newone = GetArcMemory (Destination);
 
   r_delete_entry (Source->arc_tree, (BoxTypePtr) Arc);
   /* copy the data and remove it from the former layer */
-  *new = *Arc;
+  *newone = *Arc;
   *Arc = Source->Arc[--Source->ArcN];
   r_substitute (Source->arc_tree, (BoxType *) & Source->Arc[Source->ArcN],
 		(BoxType *) Arc);
   memset (&Source->Arc[Source->ArcN], 0, sizeof (ArcType));
   if (!Destination->arc_tree)
     Destination->arc_tree = r_create_tree (NULL, 0, 0);
-  r_insert_entry (Destination->arc_tree, (BoxTypePtr) new, 0);
-  return (new);
+  r_insert_entry (Destination->arc_tree, (BoxTypePtr) newone, 0);
+  return (newone);
 }
 
 
@@ -483,7 +483,7 @@ MoveArcToLayerLowLevel (LayerTypePtr Source, ArcTypePtr Arc,
 static void *
 MoveArcToLayer (LayerTypePtr Layer, ArcTypePtr Arc)
 {
-  ArcTypePtr new;
+  ArcTypePtr newone;
 
   if (TEST_FLAG (LOCKFLAG, Arc))
     {
@@ -501,12 +501,12 @@ MoveArcToLayer (LayerTypePtr Layer, ArcTypePtr Arc)
   RestoreToPolygon (PCB->Data, ARC_TYPE, Layer, Arc);
   if (Layer->On)
     EraseArc (Arc);
-  new = MoveArcToLayerLowLevel (Layer, Arc, Dest);
+  newone = (ArcTypePtr)MoveArcToLayerLowLevel (Layer, Arc, Dest);
   ClearFromPolygon (PCB->Data, ARC_TYPE, Dest, Arc);
   if (Dest->On)
-    DrawArc (Dest, new, 0);
+    DrawArc (Dest, newone, 0);
   Draw ();
-  return (new);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
@@ -515,7 +515,7 @@ MoveArcToLayer (LayerTypePtr Layer, ArcTypePtr Arc)
 static void *
 MoveRatToLayer (RatTypePtr Rat)
 {
-  LineTypePtr new;
+  LineTypePtr newone;
   //LocationType X1 = Rat->Point1.X, Y1 = Rat->Point1.Y;
   //LocationType X1 = Rat->Point1.X, Y1 = Rat->Point1.Y;
   // if VIAFLAG
@@ -523,21 +523,21 @@ MoveRatToLayer (RatTypePtr Rat)
   //   else make a via and a wire, but 0-length wire not good
   // else as before
 
-  new = CreateNewLineOnLayer (Dest, Rat->Point1.X, Rat->Point1.Y,
+  newone = CreateNewLineOnLayer (Dest, Rat->Point1.X, Rat->Point1.Y,
 			      Rat->Point2.X, Rat->Point2.Y,
 			      Settings.LineThickness, 2 * Settings.Keepaway,
 			      Rat->Flags);
   if (TEST_FLAG (CLEARNEWFLAG, PCB))
-    SET_FLAG (CLEARLINEFLAG, new);
-  if (!new)
+    SET_FLAG (CLEARLINEFLAG, newone);
+  if (!newone)
     return (NULL);
-  AddObjectToCreateUndoList (LINE_TYPE, Dest, new, new);
+  AddObjectToCreateUndoList (LINE_TYPE, Dest, newone, newone);
   if (PCB->RatOn)
     EraseRat (Rat);
   MoveObjectToRemoveUndoList (RATLINE_TYPE, Rat, Rat, Rat);
-  DrawLine (Dest, new, 0);
+  DrawLine (Dest, newone, 0);
   Draw ();
-  return (new);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
@@ -573,7 +573,7 @@ MoveLineToLayer (LayerTypePtr Layer, LineTypePtr Line)
 {
   struct via_info info;
   BoxType sb;
-  LineTypePtr new;
+  LineTypePtr newone;
   void *ptr1, *ptr2, *ptr3;
 
   if (TEST_FLAG (LOCKFLAG, Line))
@@ -593,48 +593,48 @@ MoveLineToLayer (LayerTypePtr Layer, LineTypePtr Line)
   if (Layer->On)
     EraseLine (Line);
   RestoreToPolygon (PCB->Data, LINE_TYPE, Layer, Line);
-  new = MoveLineToLayerLowLevel (Layer, Line, Dest);
+  newone = (LineTypePtr)MoveLineToLayerLowLevel (Layer, Line, Dest);
   Line = NULL;
-  ClearFromPolygon (PCB->Data, LINE_TYPE, Dest, new);
+  ClearFromPolygon (PCB->Data, LINE_TYPE, Dest, newone);
   if (Dest->On)
-    DrawLine (Dest, new, 0);
+    DrawLine (Dest, newone, 0);
   Draw ();
   if (!PCB->ViaOn || MoreToCome ||
       GetLayerGroupNumberByPointer (Layer) ==
       GetLayerGroupNumberByPointer (Dest) ||
       TEST_SILK_LAYER(Layer) ||
       TEST_SILK_LAYER(Dest))
-    return (new);
+    return (newone);
   /* consider via at Point1 */
-  sb.X1 = new->Point1.X - new->Thickness / 2;
-  sb.X2 = new->Point1.X + new->Thickness / 2;
-  sb.Y1 = new->Point1.Y - new->Thickness / 2;
-  sb.Y2 = new->Point1.Y + new->Thickness / 2;
+  sb.X1 = newone->Point1.X - newone->Thickness / 2;
+  sb.X2 = newone->Point1.X + newone->Thickness / 2;
+  sb.Y1 = newone->Point1.Y - newone->Thickness / 2;
+  sb.Y2 = newone->Point1.Y + newone->Thickness / 2;
   if ((SearchObjectByLocation (PIN_TYPES, &ptr1, &ptr2, &ptr3,
-			       new->Point1.X, new->Point1.Y,
+			       newone->Point1.X, newone->Point1.Y,
 			       Settings.ViaThickness / 2) == NO_TYPE))
     {
-      info.X = new->Point1.X;
-      info.Y = new->Point1.Y;
+      info.X = newone->Point1.X;
+      info.Y = newone->Point1.Y;
       if (setjmp (info.env) == 0)
 	r_search (Layer->line_tree, &sb, NULL, moveline_callback, &info);
     }
   /* consider via at Point2 */
-  sb.X1 = new->Point2.X - new->Thickness / 2;
-  sb.X2 = new->Point2.X + new->Thickness / 2;
-  sb.Y1 = new->Point2.Y - new->Thickness / 2;
-  sb.Y2 = new->Point2.Y + new->Thickness / 2;
+  sb.X1 = newone->Point2.X - newone->Thickness / 2;
+  sb.X2 = newone->Point2.X + newone->Thickness / 2;
+  sb.Y1 = newone->Point2.Y - newone->Thickness / 2;
+  sb.Y2 = newone->Point2.Y + newone->Thickness / 2;
   if ((SearchObjectByLocation (PIN_TYPES, &ptr1, &ptr2, &ptr3,
-			       new->Point2.X, new->Point2.Y,
+			       newone->Point2.X, newone->Point2.Y,
 			       Settings.ViaThickness / 2) == NO_TYPE))
     {
-      info.X = new->Point2.X;
-      info.Y = new->Point2.Y;
+      info.X = newone->Point2.X;
+      info.Y = newone->Point2.Y;
       if (setjmp (info.env) == 0)
 	r_search (Layer->line_tree, &sb, NULL, moveline_callback, &info);
     }
   Draw ();
-  return (new);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
@@ -644,28 +644,28 @@ void *
 MoveTextToLayerLowLevel (LayerTypePtr Source, TextTypePtr Text,
 			 LayerTypePtr Destination)
 {
-  TextTypePtr new = GetTextMemory (Destination);
+  TextTypePtr newone = GetTextMemory (Destination);
 
   RestoreToPolygon (PCB->Data, TEXT_TYPE, Source, Text);
   r_delete_entry (Source->text_tree, (BoxTypePtr) Text);
   /* copy the data and remove it from the former layer */
-  *new = *Text;
+  *newone = *Text;
   *Text = Source->Text[--Source->TextN];
   r_substitute (Source->text_tree, (BoxType *) & Source->Text[Source->TextN],
 		(BoxType *) Text);
   memset (&Source->Text[Source->TextN], 0, sizeof (TextType));
   if (GetLayerGroupNumberByNumber (solder_silk_layer) ==
       GetLayerGroupNumberByPointer (Destination))
-    SET_FLAG (ONSOLDERFLAG, new);
+    SET_FLAG (ONSOLDERFLAG, newone);
   else
-    CLEAR_FLAG (ONSOLDERFLAG, new);
+    CLEAR_FLAG (ONSOLDERFLAG, newone);
   /* re-calculate the bounding box (it could be mirrored now) */
-  SetTextBoundingBox (&PCB->Font, new);
+  SetTextBoundingBox (&PCB->Font, newone);
   if (!Destination->text_tree)
     Destination->text_tree = r_create_tree (NULL, 0, 0);
-  r_insert_entry (Destination->text_tree, (BoxTypePtr) new, 0);
-  ClearFromPolygon (PCB->Data, TEXT_TYPE, Destination, new);
-  return (new);
+  r_insert_entry (Destination->text_tree, (BoxTypePtr) newone, 0);
+  ClearFromPolygon (PCB->Data, TEXT_TYPE, Destination, newone);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
@@ -674,7 +674,7 @@ MoveTextToLayerLowLevel (LayerTypePtr Source, TextTypePtr Text,
 static void *
 MoveTextToLayer (LayerTypePtr Layer, TextTypePtr Text)
 {
-  TextTypePtr new;
+  TextTypePtr newone;
 
   if (TEST_FLAG (LOCKFLAG, Text))
     {
@@ -686,12 +686,12 @@ MoveTextToLayer (LayerTypePtr Layer, TextTypePtr Text)
       AddObjectToMoveToLayerUndoList (TEXT_TYPE, Layer, Text, Text);
       if (Layer->On)
 	EraseText (Layer, Text);
-      new = MoveTextToLayerLowLevel (Layer, Text, Dest);
+      newone = (TextTypePtr)MoveTextToLayerLowLevel (Layer, Text, Dest);
       if (Dest->On)
-	DrawText (Dest, new, 0);
+	DrawText (Dest, newone, 0);
       if (Layer->On || Dest->On)
 	Draw ();
-      return (new);
+      return (newone);
     }
   return (Text);
 }
@@ -703,11 +703,11 @@ void *
 MovePolygonToLayerLowLevel (LayerTypePtr Source, PolygonTypePtr Polygon,
 			    LayerTypePtr Destination)
 {
-  PolygonTypePtr new = GetPolygonMemory (Destination);
+  PolygonTypePtr newone = GetPolygonMemory (Destination);
 
   r_delete_entry (Source->polygon_tree, (BoxType *) Polygon);
   /* copy the data and remove it from the former layer */
-  *new = *Polygon;
+  *newone = *Polygon;
   *Polygon = Source->Polygon[--Source->PolygonN];
   r_substitute (Source->polygon_tree,
 		(BoxType *) & Source->Polygon[Source->PolygonN],
@@ -715,8 +715,8 @@ MovePolygonToLayerLowLevel (LayerTypePtr Source, PolygonTypePtr Polygon,
   memset (&Source->Polygon[Source->PolygonN], 0, sizeof (PolygonType));
   if (!Destination->polygon_tree)
     Destination->polygon_tree = r_create_tree (NULL, 0, 0);
-  r_insert_entry (Destination->polygon_tree, (BoxType *) new, 0);
-  return (new);
+  r_insert_entry (Destination->polygon_tree, (BoxType *) newone, 0);
+  return (newone);
 }
 
 struct mptlc
@@ -750,7 +750,7 @@ mptl_pin_callback (const BoxType *b, void *cl)
 static void *
 MovePolygonToLayer (LayerTypePtr Layer, PolygonTypePtr Polygon)
 {
-  PolygonTypePtr new;
+  PolygonTypePtr newone;
   struct mptlc d;
 
   if (TEST_FLAG (LOCKFLAG, Polygon))
@@ -771,14 +771,14 @@ MovePolygonToLayer (LayerTypePtr Layer, PolygonTypePtr Polygon)
   r_search (PCB->Data->pin_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d);
   d.type = VIA_TYPE;
   r_search (PCB->Data->via_tree, &Polygon->BoundingBox, NULL, mptl_pin_callback, &d);
-  new = MovePolygonToLayerLowLevel (Layer, Polygon, Dest);
-  InitClip (PCB->Data, Dest, new);
+  newone = (struct polygon_st *)MovePolygonToLayerLowLevel (Layer, Polygon, Dest);
+  InitClip (PCB->Data, Dest, newone);
   if (Dest->On)
     {
-      DrawPolygon (Dest, new, 0);
+      DrawPolygon (Dest, newone, 0);
       Draw ();
     }
-  return (new);
+  return (newone);
 }
 
 /* ---------------------------------------------------------------------------
diff --git a/src/mtspace.c b/src/mtspace.c
index 3640f5c..9d593e8 100644
--- a/src/mtspace.c
+++ b/src/mtspace.c
@@ -104,7 +104,7 @@ mtspace_create_box (const BoxType * box, BDimension keepaway)
 {
   mtspacebox_t *mtsb;
   assert (box_is_good (box));
-  mtsb = malloc (sizeof (*mtsb));
+  mtsb = (mtspacebox_t *)malloc (sizeof (*mtsb));
   /* the box was sent to us pre-bloated by the keepaway amount */
   *((BoxTypePtr) & mtsb->box) = *box;
   mtsb->keepaway = keepaway;
@@ -119,7 +119,7 @@ mtspace_create (void)
   mtspace_t *mtspace;
 
   /* create mtspace data structure */
-  mtspace = malloc (sizeof (*mtspace));
+  mtspace = (mtspace_t *)malloc (sizeof (*mtspace));
   mtspace->ftree = r_create_tree (NULL, 0, 0);
   mtspace->etree = r_create_tree (NULL, 0, 0);
   mtspace->otree = r_create_tree (NULL, 0, 0);
@@ -220,21 +220,21 @@ struct query_closure
 };
 
 static inline void
-heap_append (heap_t *heap, CheapPointType *desired, BoxType *new)
+heap_append (heap_t *heap, CheapPointType *desired, BoxType *newone)
 {
   CheapPointType p = *desired;
   assert (desired);
-  closest_point_in_box (&p, new);
-  heap_insert (heap, ABS(p.X - desired->X) + (p.Y - desired->Y), new);
+  closest_point_in_box (&p, newone);
+  heap_insert (heap, ABS(p.X - desired->X) + (p.Y - desired->Y), newone);
 }
 
 static inline void
-append (struct query_closure * qc, BoxType *new)
+append (struct query_closure * qc, BoxType *newone)
 { 
   if (qc->desired)
-    heap_append (qc->checking.h, qc->desired, new);
+    heap_append (qc->checking.h, qc->desired, newone);
   else
-    vector_append (qc->checking.v, new);
+    vector_append (qc->checking.v, newone);
 }
 
 /* we found some space filler that may intersect this query.
@@ -267,13 +267,13 @@ query_one (const BoxType * box, void *cl)
       int Y2 = mtsb->box.Y1 + shrink;
       if (Y2 - Y1 >= 2 * (qc->radius + qc->keepaway))
 	{
-	  BoxType *new = (BoxType *) malloc (sizeof (BoxType));
-	  new->X1 = qc->cbox->X1;
-	  new->X2 = qc->cbox->X2;
-	  new->Y1 = Y1;
-	  new->Y2 = Y2;
-	  assert (new->Y2 < qc->cbox->Y2);
-          append(qc, new);
+	  BoxType *newone = (BoxType *) malloc (sizeof (BoxType));
+	  newone->X1 = qc->cbox->X1;
+	  newone->X2 = qc->cbox->X2;
+	  newone->Y1 = Y1;
+	  newone->Y2 = Y2;
+	  assert (newone->Y2 < qc->cbox->Y2);
+          append(qc, newone);
 	}
     }
   if (mtsb->box.Y2 < qc->cbox->Y2 - shrink)	/* bottom region exists */
@@ -282,13 +282,13 @@ query_one (const BoxType * box, void *cl)
       int Y2 = qc->cbox->Y2;
       if (Y2 - Y1 >= 2 * (qc->radius + qc->keepaway))
 	{
-	  BoxType *new = (BoxType *) malloc (sizeof (BoxType));
-	  new->X1 = qc->cbox->X1;
-	  new->X2 = qc->cbox->X2;
-	  new->Y2 = qc->cbox->Y2;
-	  new->Y1 = Y1;
-	  assert (new->Y1 > qc->cbox->Y1);
-	  append (qc, new);
+	  BoxType *newone = (BoxType *) malloc (sizeof (BoxType));
+	  newone->X1 = qc->cbox->X1;
+	  newone->X2 = qc->cbox->X2;
+	  newone->Y2 = qc->cbox->Y2;
+	  newone->Y1 = Y1;
+	  assert (newone->Y1 > qc->cbox->Y1);
+	  append (qc, newone);
 	}
     }
   if (mtsb->box.X1 > qc->cbox->X1 + shrink)	/* left region exists */
@@ -297,14 +297,14 @@ query_one (const BoxType * box, void *cl)
       int X2 = mtsb->box.X1 + shrink;
       if (X2 - X1 >= 2 * (qc->radius + qc->keepaway))
 	{
-	  BoxType *new;
-	  new = (BoxType *) malloc (sizeof (BoxType));
-	  new->Y1 = qc->cbox->Y1;
-	  new->Y2 = qc->cbox->Y2;
-	  new->X1 = qc->cbox->X1;
-	  new->X2 = X2;
-	  assert (new->X2 < qc->cbox->X2);
-	  append (qc, new);
+	  BoxType *newone;
+	  newone = (BoxType *) malloc (sizeof (BoxType));
+	  newone->Y1 = qc->cbox->Y1;
+	  newone->Y2 = qc->cbox->Y2;
+	  newone->X1 = qc->cbox->X1;
+	  newone->X2 = X2;
+	  assert (newone->X2 < qc->cbox->X2);
+	  append (qc, newone);
 	}
     }
   if (mtsb->box.X2 < qc->cbox->X2 - shrink)	/* right region exists */
@@ -313,13 +313,13 @@ query_one (const BoxType * box, void *cl)
       int X2 = qc->cbox->X2;
       if (X2 - X1 >= 2 * (qc->radius + qc->keepaway))
 	{
-	  BoxType *new = (BoxType *) malloc (sizeof (BoxType));
-	  new->Y1 = qc->cbox->Y1;
-	  new->Y2 = qc->cbox->Y2;
-	  new->X2 = qc->cbox->X2;
-	  new->X1 = X1;
-	  assert (new->X1 > qc->cbox->X1);
-	  append (qc, new);
+	  BoxType *newone = (BoxType *) malloc (sizeof (BoxType));
+	  newone->Y1 = qc->cbox->Y1;
+	  newone->Y2 = qc->cbox->Y2;
+	  newone->X2 = qc->cbox->X2;
+	  newone->X1 = X1;
+	  assert (newone->X1 > qc->cbox->X1);
+	  append (qc, newone);
 	}
     }
   if (qc->touching.v)
@@ -352,7 +352,7 @@ qloop (struct query_closure *qc, rtree_t * tree, heap_or_vector res, bool is_vec
 #endif
   while (!(qc->desired ? heap_is_empty (qc->checking.h) : vector_is_empty (qc->checking.v)))
     {
-      cbox = qc->desired ? heap_remove_smallest (qc->checking.h) : vector_remove_last (qc->checking.v);
+      cbox = qc->desired ? (BoxTypePtr)heap_remove_smallest (qc->checking.h) : (BoxTypePtr)vector_remove_last (qc->checking.v);
       if (setjmp (qc->env) == 0)
 	{
 	  assert (box_is_good (cbox));
@@ -490,6 +490,7 @@ mtspace_query_rect (mtspace_t * mtspace, const BoxType * region,
   /* do the query */
   do
     {
+      heap_or_vector temporary = {free_space_vec};
       /* search the fixed object tree discarding any intersections
        * and placing empty regions in the no_fix vector.
        */
@@ -512,7 +513,9 @@ mtspace_query_rect (mtspace_t * mtspace, const BoxType * region,
 /* XXX lo_conflict_space_vec will be treated like a heap! */
       qc.touching.v = (with_conflicts ? lo_conflict_space_vec : NULL);
       qc.touch_is_vec = true;
-      qloop (&qc, is_odd ? mtspace->etree : mtspace->otree, (heap_or_vector)free_space_vec, true);
+      qloop (&qc, is_odd ? mtspace->etree : mtspace->otree, temporary, true);
+
+      /* qloop (&qc, is_odd ? mtspace->etree : mtspace->otree, (heap_or_vector)free_space_vec, true); */
       if (!vector_is_empty (free_space_vec))
 	{
 	  if (qc.desired)
@@ -533,10 +536,14 @@ mtspace_query_rect (mtspace_t * mtspace, const BoxType * region,
        */
       if (with_conflicts)
 	{
+	  heap_or_vector temporary = {hi_conflict_space_vec};
 	  qc.checking = work->hi_candidate;
 	  qc.touching.v = NULL;
 	  qloop (&qc, is_odd ? mtspace->etree : mtspace->otree,
-		 (heap_or_vector)hi_conflict_space_vec, true);
+		 temporary, true);
+
+	  /* qloop (&qc, is_odd ? mtspace->etree : mtspace->otree, */
+	  /* 	 (heap_or_vector)hi_conflict_space_vec, true); */
 	}
     }
   while (!(qc.desired ? heap_is_empty(work->untested.h) : vector_is_empty (work->untested.v)));
diff --git a/src/mymem.c b/src/mymem.c
index 09cb6ab..24f20a2 100644
--- a/src/mymem.c
+++ b/src/mymem.c
@@ -69,7 +69,7 @@ GetRubberbandMemory (void)
       Crosshair.AttachedObject.RubberbandMax)
     {
       Crosshair.AttachedObject.RubberbandMax += STEP_RUBBERBAND;
-      ptr = realloc (ptr, Crosshair.AttachedObject.RubberbandMax *
+      ptr = (RubberbandTypePtr)realloc (ptr, Crosshair.AttachedObject.RubberbandMax *
                           sizeof (RubberbandType));
       Crosshair.AttachedObject.Rubberband = ptr;
       memset (ptr + Crosshair.AttachedObject.RubberbandN, 0,
@@ -87,7 +87,7 @@ GetPointerMemory (PointerListTypePtr list)
   if (list->PtrN >= list->PtrMax)
     {
       list->PtrMax = STEP_POINT + (2 * list->PtrMax);
-      ptr = realloc (ptr, list->PtrMax * sizeof (void *));
+      ptr = (void **)realloc (ptr, list->PtrMax * sizeof (void *));
       list->Ptr = ptr;
       memset (ptr + list->PtrN, 0,
 	      (list->PtrMax - list->PtrN) * sizeof (void *));
@@ -114,7 +114,7 @@ GetBoxMemory (BoxListTypePtr Boxes)
   if (Boxes->BoxN >= Boxes->BoxMax)
     {
       Boxes->BoxMax = STEP_POINT + (2 * Boxes->BoxMax);
-      box = realloc (box, Boxes->BoxMax * sizeof (BoxType));
+      box = (BoxTypePtr)realloc (box, Boxes->BoxMax * sizeof (BoxType));
       Boxes->Box = box;
       memset (box + Boxes->BoxN, 0,
 	      (Boxes->BoxMax - Boxes->BoxN) * sizeof (BoxType));
@@ -135,7 +135,7 @@ GetConnectionMemory (NetTypePtr Net)
   if (Net->ConnectionN >= Net->ConnectionMax)
     {
       Net->ConnectionMax += STEP_POINT;
-      con = realloc (con, Net->ConnectionMax * sizeof (ConnectionType));
+      con = (ConnectionTypePtr)realloc (con, Net->ConnectionMax * sizeof (ConnectionType));
       Net->Connection = con;
       memset (con + Net->ConnectionN, 0,
 	      STEP_POINT * sizeof (ConnectionType));
@@ -155,7 +155,7 @@ GetNetMemory (NetListTypePtr Netlist)
   if (Netlist->NetN >= Netlist->NetMax)
     {
       Netlist->NetMax += STEP_POINT;
-      net = realloc (net, Netlist->NetMax * sizeof (NetType));
+      net = (NetTypePtr)realloc (net, Netlist->NetMax * sizeof (NetType));
       Netlist->Net = net;
       memset (net + Netlist->NetN, 0, STEP_POINT * sizeof (NetType));
     }
@@ -174,7 +174,7 @@ GetNetListMemory (NetListListTypePtr Netlistlist)
   if (Netlistlist->NetListN >= Netlistlist->NetListMax)
     {
       Netlistlist->NetListMax += STEP_POINT;
-      netlist = realloc (netlist,
+      netlist = (NetListTypePtr)realloc (netlist,
                          Netlistlist->NetListMax * sizeof (NetListType));
       Netlistlist->NetList = netlist;
       memset (netlist + Netlistlist->NetListN, 0,
@@ -205,7 +205,7 @@ GetPinMemory (ElementTypePtr Element)
 	  END_LOOP;
 	}
       Element->PinMax += STEP_PIN;
-      pin = realloc (pin, Element->PinMax * sizeof (PinType));
+      pin = (PinTypePtr)realloc (pin, Element->PinMax * sizeof (PinType));
       Element->Pin = pin;
       memset (pin + Element->PinN, 0, STEP_PIN * sizeof (PinType));
       if (onBoard)
@@ -242,7 +242,7 @@ GetPadMemory (ElementTypePtr Element)
 	  END_LOOP;
 	}
       Element->PadMax += STEP_PAD;
-      pad = realloc (pad, Element->PadMax * sizeof (PadType));
+      pad = (PadTypePtr)realloc (pad, Element->PadMax * sizeof (PadType));
       Element->Pad = pad;
       memset (pad + Element->PadN, 0, STEP_PAD * sizeof (PadType));
       if (onBoard)
@@ -271,7 +271,7 @@ GetViaMemory (DataTypePtr Data)
       Data->ViaMax += STEP_VIA;
       if (Data->via_tree)
 	r_destroy_tree (&Data->via_tree);
-      via = realloc (via, Data->ViaMax * sizeof (PinType));
+      via = (PinTypePtr)realloc (via, Data->ViaMax * sizeof (PinType));
       Data->Via = via;
       memset (via + Data->ViaN, 0, STEP_VIA * sizeof (PinType));
       Data->via_tree = r_create_tree (NULL, 0, 0);
@@ -299,7 +299,7 @@ GetRatMemory (DataTypePtr Data)
       /* all of the pointers move, so rebuild the whole tree */
       if (Data->rat_tree)
         r_destroy_tree (&Data->rat_tree);
-      rat = realloc (rat, Data->RatMax * sizeof (RatType));
+      rat = (RatTypePtr)realloc (rat, Data->RatMax * sizeof (RatType));
       Data->Rat = rat;
       memset (rat + Data->RatN, 0, STEP_RAT * sizeof (RatType));
       Data->rat_tree = r_create_tree (NULL, 0, 0);
@@ -327,7 +327,7 @@ GetLineMemory (LayerTypePtr Layer)
       /* all of the pointers move, so rebuild the whole tree */
       if (Layer->line_tree)
 	r_destroy_tree (&Layer->line_tree);
-      line = realloc (line, Layer->LineMax * sizeof (LineType));
+      line = (LineTypePtr)realloc (line, Layer->LineMax * sizeof (LineType));
       Layer->Line = line;
       memset (line + Layer->LineN, 0, STEP_LINE * sizeof (LineType));
       Layer->line_tree = r_create_tree (NULL, 0, 0);
@@ -354,7 +354,7 @@ GetArcMemory (LayerTypePtr Layer)
       Layer->ArcMax += STEP_ARC;
       if (Layer->arc_tree)
 	r_destroy_tree (&Layer->arc_tree);
-      arc = realloc (arc, Layer->ArcMax * sizeof (ArcType));
+      arc = (ArcTypePtr)realloc (arc, Layer->ArcMax * sizeof (ArcType));
       Layer->Arc = arc;
       memset (arc + Layer->ArcN, 0, STEP_ARC * sizeof (ArcType));
       Layer->arc_tree = r_create_tree (NULL, 0, 0);
@@ -381,7 +381,7 @@ GetTextMemory (LayerTypePtr Layer)
       Layer->TextMax += STEP_TEXT;
       if (Layer->text_tree)
 	r_destroy_tree (&Layer->text_tree);
-      text = realloc (text, Layer->TextMax * sizeof (TextType));
+      text = (TextTypePtr)realloc (text, Layer->TextMax * sizeof (TextType));
       Layer->Text = text;
       memset (text + Layer->TextN, 0, STEP_TEXT * sizeof (TextType));
       Layer->text_tree = r_create_tree (NULL, 0, 0);
@@ -408,7 +408,7 @@ GetPolygonMemory (LayerTypePtr Layer)
       Layer->PolygonMax += STEP_POLYGON;
       if (Layer->polygon_tree)
 	r_destroy_tree (&Layer->polygon_tree);
-      polygon = realloc (polygon, Layer->PolygonMax * sizeof (PolygonType));
+      polygon = (PolygonTypePtr)realloc (polygon, Layer->PolygonMax * sizeof (PolygonType));
       Layer->Polygon = polygon;
       memset (polygon + Layer->PolygonN, 0,
 	      STEP_POLYGON * sizeof (PolygonType));
@@ -435,7 +435,7 @@ GetPointMemoryInPolygon (PolygonTypePtr Polygon)
   if (Polygon->PointN >= Polygon->PointMax)
     {
       Polygon->PointMax += STEP_POLYGONPOINT;
-      points = realloc (points, Polygon->PointMax * sizeof (PointType));
+      points = (PointTypePtr)realloc (points, Polygon->PointMax * sizeof (PointType));
       Polygon->Points = points;
       memset (points + Polygon->PointN, 0,
 	      STEP_POLYGONPOINT * sizeof (PointType));
@@ -456,7 +456,7 @@ GetHoleIndexMemoryInPolygon (PolygonTypePtr Polygon)
   if (Polygon->HoleIndexN >= Polygon->HoleIndexMax)
     {
       Polygon->HoleIndexMax += STEP_POLYGONHOLEINDEX;
-      holeindex = realloc (holeindex, Polygon->HoleIndexMax * sizeof (int));
+      holeindex = (Cardinal *)realloc (holeindex, Polygon->HoleIndexMax * sizeof (int));
       Polygon->HoleIndex = holeindex;
       memset (holeindex + Polygon->HoleIndexN, 0,
 	      STEP_POLYGONHOLEINDEX * sizeof (int));
@@ -479,7 +479,7 @@ GetElementMemory (DataTypePtr Data)
       Data->ElementMax += STEP_ELEMENT;
       if (Data->element_tree)
 	r_destroy_tree (&Data->element_tree);
-      element = realloc (element, Data->ElementMax * sizeof (ElementType));
+      element = (ElementTypePtr)realloc (element, Data->ElementMax * sizeof (ElementType));
       Data->Element = element;
       memset (element + Data->ElementN, 0,
 	      STEP_ELEMENT * sizeof (ElementType));
@@ -528,7 +528,7 @@ GetLibraryMenuMemory (LibraryTypePtr lib)
   if (lib->MenuN >= lib->MenuMax)
     {
       lib->MenuMax += STEP_LIBRARYMENU;
-      menu = realloc (menu, lib->MenuMax * sizeof (LibraryMenuType));
+      menu = (LibraryMenuTypePtr)realloc (menu, lib->MenuMax * sizeof (LibraryMenuType));
       lib->Menu = menu;
       memset (menu + lib->MenuN, 0,
 	      STEP_LIBRARYMENU * sizeof (LibraryMenuType));
@@ -548,7 +548,7 @@ GetLibraryEntryMemory (LibraryMenuTypePtr Menu)
   if (Menu->EntryN >= Menu->EntryMax)
     {
       Menu->EntryMax += STEP_LIBRARYENTRY;
-      entry = realloc (entry, Menu->EntryMax * sizeof (LibraryEntryType));
+      entry = (LibraryEntryTypePtr)realloc (entry, Menu->EntryMax * sizeof (LibraryEntryType));
       Menu->Entry = entry;
       memset (entry + Menu->EntryN, 0,
 	      STEP_LIBRARYENTRY * sizeof (LibraryEntryType));
@@ -570,7 +570,7 @@ GetDrillElementMemory (DrillTypePtr Drill)
   if (Drill->ElementN >= Drill->ElementMax)
     {
       Drill->ElementMax += STEP_ELEMENT;
-      element = realloc (element,
+      element = (ElementTypePtr *)realloc (element,
                          Drill->ElementMax * sizeof (ElementTypeHandle));
       Drill->Element = element;
       memset (element + Drill->ElementN, 0,
@@ -593,7 +593,7 @@ GetDrillPinMemory (DrillTypePtr Drill)
   if (Drill->PinN >= Drill->PinMax)
     {
       Drill->PinMax += STEP_POINT;
-      pin = realloc (pin, Drill->PinMax * sizeof (PinTypeHandle));
+      pin = (PinTypePtr *)realloc (pin, Drill->PinMax * sizeof (PinTypeHandle));
       Drill->Pin = pin;
       memset (pin + Drill->PinN, 0, STEP_POINT * sizeof (PinTypeHandle));
     }
@@ -612,7 +612,7 @@ GetDrillInfoDrillMemory (DrillInfoTypePtr DrillInfo)
   if (DrillInfo->DrillN >= DrillInfo->DrillMax)
     {
       DrillInfo->DrillMax += STEP_DRILL;
-      drill = realloc (drill, DrillInfo->DrillMax * sizeof (DrillType));
+      drill = (DrillTypePtr)realloc (drill, DrillInfo->DrillMax * sizeof (DrillType));
       DrillInfo->Drill = drill;
       memset (drill + DrillInfo->DrillN, 0, STEP_DRILL * sizeof (DrillType));
     }
@@ -895,7 +895,7 @@ DSRealloc (DynamicStringTypePtr Ptr, size_t Length)
   if (input_null || Length >= Ptr->MaxLength)
     {
       Ptr->MaxLength = Length + 512;
-      Ptr->Data = realloc (Ptr->Data, Ptr->MaxLength);
+      Ptr->Data = (char *)realloc (Ptr->Data, Ptr->MaxLength);
       if (input_null)
 	Ptr->Data[0] = '\0';
     }
@@ -963,7 +963,7 @@ StripWhiteSpaceAndDup (char *S)
   /* string is not empty -> allocate memory */
   if (length)
     {
-      p2 = realloc (NULL, length + 1);
+      p2 = (char *)realloc (NULL, length + 1);
       strncpy (p2, p1, length);
       *(p2 + length) = '\0';
       return (p2);
diff --git a/src/netlist.c b/src/netlist.c
index 4a26bc9..0c004f9 100644
--- a/src/netlist.c
+++ b/src/netlist.c
@@ -388,7 +388,7 @@ Netlist (int argc, char **argv, int x, int y)
 	}
     }
   else if (strcasecmp (argv[0], "style") == 0)
-    func = (void *)netlist_style;
+    func = (NFunc)netlist_style;
   else if (strcasecmp (argv[0], "add") == 0)
     {
       /* Add is different, because the net/pin won't already exist.  */
diff --git a/src/parse_l.l b/src/parse_l.l
index 9799250..57cd1c6 100644
--- a/src/parse_l.l
+++ b/src/parse_l.l
@@ -69,7 +69,7 @@ RCSID("$Id$");
  * some shared parser identifiers
  */
 #ifdef FLEX_SCANNER
-int				yylineno;		/* linenumber */
+
 #define yyunput ATTRIBUTE_UNUSED yyunput
 #endif
 
@@ -172,7 +172,7 @@ Attribute	{ return(T_ATTRIBUTE); }
 							 * leading and trailing '"'
 							 */
 						yyleng -= 2;
-						yylval.string = calloc (yyleng+1, sizeof (char));
+						yylval.string = (char *)calloc (yyleng+1, sizeof (char));
 						p1 = (char *) (yytext +1);
 						p2 = yylval.string;
 						while(yyleng--)
diff --git a/src/parse_y.y b/src/parse_y.y
index 7aa7b80..d0f31aa 100644
--- a/src/parse_y.y
+++ b/src/parse_y.y
@@ -153,7 +153,7 @@ parsepcb
 					LayerFlag[i] = false;
 				yyFont = &yyPCB->Font;
 				yyData = yyPCB->Data;
-				yyData->pcb = (void *)yyPCB;
+				yyData->pcb = yyPCB;
 				yyData->LayerN = 0;
 				layer_group_string = NULL;
 			}
@@ -1913,7 +1913,7 @@ attributes	: attribute
 attribute
 		: T_ATTRIBUTE '(' STRING STRING ')'
 			{
-				CreateNewAttribute (attr_list, $3, $4 ? $4 : "");
+			  CreateNewAttribute (attr_list, $3, $4 ? $4 : (char *)"");
 				free ($3);
 				free ($4);
 			}
@@ -1928,8 +1928,7 @@ opt_string	: STRING { $$ = $1; }
 /* ---------------------------------------------------------------------------
  * error routine called by parser library
  */
-int yyerror(s)
-const char *s;
+int yyerror(const char * s)
 {
 	Message("ERROR parsing file '%s'\n"
 		"    line:        %i\n"
diff --git a/src/polygon.c b/src/polygon.c
index 72d92c9..c552f3c 100644
--- a/src/polygon.c
+++ b/src/polygon.c
@@ -193,7 +193,7 @@ prev_contour_point (PolygonTypePtr polygon, Cardinal point)
 static void
 add_noholes_polyarea (PLINE *pline, void *user_data)
 {
-  PolygonType *poly = user_data;
+  PolygonType *poly = (PolygonType *)user_data;
 
   /* Prepend the pline into the NoHoles linked list */
   pline->next = poly->NoHoles;
@@ -1583,7 +1583,7 @@ PlowsPolygon (DataType * Data, int type, void *ptr1, void *ptr2,
       if (!TEST_FLAG (CLEARLINEFLAG, (LineTypePtr) ptr2))
         return 0;
       /* silk doesn't plow */
-      if (GetLayerNumber (Data, ptr1) >= max_copper_layer)
+      if (GetLayerNumber (Data, (LayerTypePtr)ptr1) >= max_copper_layer)
         return 0;
       GROUP_LOOP (Data, GetLayerGroupNumberByNumber (GetLayerNumber (Data,
                                                                      ((LayerTypePtr) ptr1))));
@@ -1819,28 +1819,28 @@ MorphPolygon (LayerTypePtr layer, PolygonTypePtr poly)
   do
     {
       VNODE *v;
-      PolygonTypePtr new;
+      PolygonTypePtr newone;
 
       if (p->contours->area > PCB->IsleArea)
         {
-          new = CreateNewPolygon (layer, flags);
-          if (!new)
+          newone = CreateNewPolygon (layer, flags);
+          if (!newone)
             return false;
           many = true;
           v = &p->contours->head;
-          CreateNewPointInPolygon (new, v->point[0], v->point[1]);
+          CreateNewPointInPolygon (newone, v->point[0], v->point[1]);
           for (v = v->next; v != &p->contours->head; v = v->next)
-            CreateNewPointInPolygon (new, v->point[0], v->point[1]);
-          new->BoundingBox.X1 = p->contours->xmin;
-          new->BoundingBox.X2 = p->contours->xmax + 1;
-          new->BoundingBox.Y1 = p->contours->ymin;
-          new->BoundingBox.Y2 = p->contours->ymax + 1;
-          AddObjectToCreateUndoList (POLYGON_TYPE, layer, new, new);
-          new->Clipped = p;
+            CreateNewPointInPolygon (newone, v->point[0], v->point[1]);
+          newone->BoundingBox.X1 = p->contours->xmin;
+          newone->BoundingBox.X2 = p->contours->xmax + 1;
+          newone->BoundingBox.Y1 = p->contours->ymin;
+          newone->BoundingBox.Y2 = p->contours->ymax + 1;
+          AddObjectToCreateUndoList (POLYGON_TYPE, layer, newone, newone);
+          newone->Clipped = p;
           p = p->f;             /* go to next pline */
-          new->Clipped->b = new->Clipped->f = new->Clipped;     /* unlink from others */
-          r_insert_entry (layer->polygon_tree, (BoxType *) new, 0);
-          DrawPolygon (layer, new, 0);
+          newone->Clipped->b = newone->Clipped->f = newone->Clipped;     /* unlink from others */
+          r_insert_entry (layer->polygon_tree, (BoxType *) newone, 0);
+          DrawPolygon (layer, newone, 0);
         }
       else
         {
diff --git a/src/polygon1.c b/src/polygon1.c
index 468c139..8e9aa24 100644
--- a/src/polygon1.c
+++ b/src/polygon1.c
@@ -95,7 +95,7 @@ int vect_inters2 (Vector A, Vector B, Vector C, Vector D, Vector S1,
 #define error(code)  longjmp(*(e), code)
 
 #define MemGet(ptr, type) \
-if (UNLIKELY (((ptr) = malloc(sizeof(type))) == NULL)) \
+  if (UNLIKELY (((ptr) = (type *)malloc(sizeof(type))) == NULL))	\
     error(err_no_memory);
 
 #undef DEBUG_LABEL
@@ -276,16 +276,16 @@ insert_descriptor
 static CVCList *
 insert_descriptor (VNODE * a, char poly, char side, CVCList * start)
 {
-  CVCList *l, *new, *big, *small;
+  CVCList *l, *newone, *big, *small;
 
-  if (!(new = new_descriptor (a, poly, side)))
+  if (!(newone = new_descriptor (a, poly, side)))
     return NULL;
   /* search for the CVCList for this point */
   if (!start)
     {
-      start = new;		/* return is also new, so we know where start is */
-      start->head = new;	/* circular list */
-      return new;
+      start = newone;		/* return is also new, so we know where start is */
+      start->head = newone;	/* circular list */
+      return newone;
     }
   else
     {
@@ -297,7 +297,7 @@ insert_descriptor (VNODE * a, char poly, char side, CVCList * start)
 	      && l->parent->point[1] == a->point[1])
 	    {			/* this CVCList is at our point */
 	      start = l;
-	      new->head = l->head;
+	      newone->head = l->head;
 	      break;
 	    }
 	  if (l->head->parent->point[0] == start->parent->point[0]
@@ -305,10 +305,10 @@ insert_descriptor (VNODE * a, char poly, char side, CVCList * start)
 	    {
 	      /* this seems to be a new point */
 	      /* link this cvclist to the list of all cvclists */
-	      for (; l->head != new; l = l->next)
-		l->head = new;
-	      new->head = start;
-	      return new;
+	      for (; l->head != newone; l = l->next)
+		l->head = newone;
+	      newone->head = start;
+	      return newone;
 	    }
 	  l = l->head;
 	}
@@ -323,29 +323,29 @@ insert_descriptor (VNODE * a, char poly, char side, CVCList * start)
 	  small = l->next;
 	  big = l;
 	}
-      else if (new->angle >= l->angle && new->angle <= l->next->angle)
+      else if (newone->angle >= l->angle && newone->angle <= l->next->angle)
 	{
 	  /* insert new cvc if it lies between existing points */
-	  new->prev = l;
-	  new->next = l->next;
-	  l->next = l->next->prev = new;
-	  return new;
+	  newone->prev = l;
+	  newone->next = l->next;
+	  l->next = l->next->prev = newone;
+	  return newone;
 	}
     }
   while ((l = l->next) != start);
   /* didn't find it between points, it must go on an end */
-  if (big->angle <= new->angle)
+  if (big->angle <= newone->angle)
     {
-      new->prev = big;
-      new->next = big->next;
-      big->next = big->next->prev = new;
-      return new;
+      newone->prev = big;
+      newone->next = big->next;
+      big->next = big->next->prev = newone;
+      return newone;
     }
-  assert (small->angle >= new->angle);
-  new->next = small;
-  new->prev = small->prev;
-  small->prev = small->prev->next = new;
-  return new;
+  assert (small->angle >= newone->angle);
+  newone->next = small;
+  newone->prev = small->prev;
+  small->prev = small->prev->next = newone;
+  return newone;
 }
 
 /*
@@ -503,7 +503,7 @@ typedef struct _insert_node_task insert_node_task;
 struct _insert_node_task
 {
   insert_node_task *next;
-  seg *seg;
+  seg * node_seg;
   VNODE *new_node;
 };
 
@@ -539,7 +539,7 @@ adjust_tree (rtree_t * tree, struct seg *s)
 {
   struct seg *q;
 
-  q = malloc (sizeof (struct seg));
+  q = (seg *)malloc (sizeof (struct seg));
   if (!q)
     return 1;
   q->intersected = 0;
@@ -550,7 +550,7 @@ adjust_tree (rtree_t * tree, struct seg *s)
   q->box.Y1 = min (q->v->point[1], q->v->next->point[1]);
   q->box.Y2 = max (q->v->point[1], q->v->next->point[1]) + 1;
   r_insert_entry (tree, (const BoxType *) q, 1);
-  q = malloc (sizeof (struct seg));
+  q = (seg *)malloc (sizeof (struct seg));
   if (!q)
     return 1;
   q->intersected = 0;
@@ -591,8 +591,8 @@ seg_in_region (const BoxType * b, void *cl)
 static insert_node_task *
 prepend_insert_node_task (insert_node_task *list, seg *seg, VNODE *new_node)
 {
-  insert_node_task *task = malloc (sizeof (*task));
-  task->seg = seg;
+  insert_node_task *task = (insert_node_task *)malloc (sizeof (*task));
+  task->node_seg = seg;
   task->new_node = new_node;
   task->next = list;
   return task;
@@ -678,7 +678,7 @@ make_edge_tree (PLINE * pb)
   bv = &pb->head;
   do
     {
-      s = malloc (sizeof (struct seg));
+      s = (seg *)malloc (sizeof (struct seg));
       s->intersected = 0;
       if (bv->point[0] < bv->next->point[0])
 	{
@@ -879,14 +879,14 @@ intersect_impl (jmp_buf * jb, POLYAREA * b, POLYAREA * a, int add)
       insert_node_task *next = task->next;
 
       /* Do insersion */
-      task->new_node->prev = task->seg->v;
-      task->new_node->next = task->seg->v->next;
-      task->seg->v->next->prev = task->new_node;
-      task->seg->v->next = task->new_node;
-      task->seg->p->Count++;
-
-      cntrbox_adjust (task->seg->p, task->new_node->point);
-      if (adjust_tree (task->seg->p->tree, task->seg))
+      task->new_node->prev = task->node_seg->v;
+      task->new_node->next = task->node_seg->v->next;
+      task->node_seg->v->next->prev = task->new_node;
+      task->node_seg->v->next = task->new_node;
+      task->node_seg->p->Count++;
+
+      cntrbox_adjust (task->node_seg->p, task->new_node->point);
+      if (adjust_tree (task->node_seg->p->tree, task->node_seg))
 	assert (0); /* XXX: Memory allocation failure */
 
       need_restart = 1; /* Any new nodes could intersect */
@@ -967,7 +967,7 @@ cntrbox_inside (PLINE * c1, PLINE * c2)
 static int
 count_contours_i_am_inside (const BoxType * b, void *cl)
 {
-  PLINE *me = cl;
+  PLINE *me = (PLINE *) cl;
   PLINE *check = (PLINE *) b;
 
   if (poly_ContourInContour (check, me))
@@ -1276,7 +1276,7 @@ struct find_inside_info
 static int
 find_inside (const BoxType * b, void *cl)
 {
-  struct find_inside_info *info = cl;
+  struct find_inside_info *info = (struct find_inside_info *) cl;
   PLINE *check = (PLINE *) b;
   /* Do test on check to see if it inside info->want_inside */
   /* If it is: */
@@ -1318,7 +1318,7 @@ InsertHoles (jmp_buf * e, POLYAREA * dest, PLINE ** src)
 
   /* make a polyarea info table */
   /* make an rtree of polyarea info table */
-  all_pa_info = malloc (sizeof (struct polyarea_info) * num_polyareas);
+  all_pa_info = (struct polyarea_info *) malloc (sizeof (struct polyarea_info) * num_polyareas);
   tree = r_create_tree (NULL, 0, 0);
   i = 0;
   curc = dest;
@@ -1357,7 +1357,7 @@ InsertHoles (jmp_buf * e, POLYAREA * dest, PLINE ** src)
        * in the heap, assume it is the container without the expense of
        * proving it.
        */
-      pa_info = heap_remove_smallest (heap);
+      pa_info = (struct polyarea_info *) heap_remove_smallest (heap);
       if (heap_is_empty (heap))
 	{			/* only one possibility it must be the right one */
 	  assert (poly_ContourInContour (pa_info->pa->contours, curh));
@@ -1374,7 +1374,7 @@ InsertHoles (jmp_buf * e, POLYAREA * dest, PLINE ** src)
 		}
 	      if (heap_is_empty (heap))
 		break;
-	      pa_info = heap_remove_smallest (heap);
+	      pa_info = (struct polyarea_info *) heap_remove_smallest (heap);
 	    }
 	  while (1);
 	}
@@ -1562,7 +1562,7 @@ jump (VNODE ** cur, DIRECTION * cdir, J_Rule rule)
 {
   CVCList *d, *start;
   VNODE *e;
-  DIRECTION new;
+  DIRECTION newone;
 
   if (!(*cur)->cvc_prev)	/* not a cross-vertex */
     {
@@ -1584,14 +1584,14 @@ jump (VNODE ** cur, DIRECTION * cdir, J_Rule rule)
       e = d->parent;
       if (d->side == 'P')
 	e = e->prev;
-      new = *cdir;
-      if (!e->Flags.mark && rule (d->poly, e, &new))
+      newone = *cdir;
+      if (!e->Flags.mark && rule (d->poly, e, &newone))
 	{
-	  if ((d->side == 'N' && new == FORW) ||
-	      (d->side == 'P' && new == BACKW))
+	  if ((d->side == 'N' && newone == FORW) ||
+	      (d->side == 'P' && newone == BACKW))
 	    {
 #ifdef DEBUG_JUMP
-	      if (new == FORW)
+	      if (newone == FORW)
 		DEBUGP ("jump leaving node at (%d, %d)\n",
 			e->next->point[0], e->next->point[1]);
 	      else
@@ -1599,7 +1599,7 @@ jump (VNODE ** cur, DIRECTION * cdir, J_Rule rule)
 			e->point[0], e->point[1]);
 #endif
 	      *cur = d->parent;
-	      *cdir = new;
+	      *cdir = newone;
 	      return TRUE;
 	    }
 	}
@@ -1958,7 +1958,7 @@ struct find_inside_m_pa_info
 static int
 find_inside_m_pa (const BoxType * b, void *cl)
 {
-  struct find_inside_m_pa_info *info = cl;
+  struct find_inside_m_pa_info *info = (struct find_inside_m_pa_info *) cl;
   PLINE *check = (PLINE *) b;
   /* Don't report for the main contour */
   if (check->Flags.orient == PLF_DIR)
@@ -2638,7 +2638,7 @@ poly_PreContour (PLINE * C, BOOLp optimize)
   C->area = ABS (area);
   if (C->Count > 2)
     C->Flags.orient = ((area < 0) ? PLF_INV : PLF_DIR);
-  C->tree = make_edge_tree (C);
+  C->tree = (rtree_t *)make_edge_tree (C);
 }				/* poly_PreContour */
 
 static int
@@ -2736,7 +2736,7 @@ poly_CopyContour (PLINE ** dst, PLINE * src)
       // newnode->Flags = cur->Flags;
       poly_InclVertex ((*dst)->head.prev, newnode);
     }
-  (*dst)->tree = make_edge_tree (*dst);
+  (*dst)->tree = (rtree_t *)make_edge_tree (*dst);
   return TRUE;
 }
 
@@ -2748,7 +2748,7 @@ poly_Copy0 (POLYAREA ** dst, const POLYAREA * src)
 {
   *dst = NULL;
   if (src != NULL)
-    *dst = calloc (1, sizeof (POLYAREA));
+    *dst = (POLYAREA *)calloc (1, sizeof (POLYAREA));
   if (*dst == NULL)
     return FALSE;
   (*dst)->contour_tree = r_create_tree (NULL, 0, 0);
@@ -3106,7 +3106,7 @@ poly_Create (void)
 {
   POLYAREA *res;
 
-  if ((res = malloc (sizeof (POLYAREA))) != NULL)
+  if ((res = (POLYAREA *)malloc (sizeof (POLYAREA))) != NULL)
     poly_Init (res);
   return res;
 }
diff --git a/src/puller.c b/src/puller.c
index 66a5a03..8e56f0b 100644
--- a/src/puller.c
+++ b/src/puller.c
@@ -1793,10 +1793,10 @@ gp_pad_cb (const BoxType *b, void *cb)
 }
 
 static void
-adjust_pointers_1 (Extra *old, Extra *new, int num, Extra *l, int n)
+adjust_pointers_1 (Extra *old, Extra *newone, int num, Extra *l, int n)
 {
-  int delta = new - old;
-  long cdelta = (char *)new - (char *)old;
+  int delta = newone - old;
+  long cdelta = (char *)newone - (char *)old;
   Extra *last = old + num;
   int i;
 
@@ -1844,10 +1844,10 @@ adjust_pointers_1 (Extra *old, Extra *new, int num, Extra *l, int n)
 }
 
 static void
-adjust_pointers (Extra *old, Extra *new, int num)
+adjust_pointers (Extra *old, Extra *newone, int num)
 {
-  adjust_pointers_1 (old, new, num, lines, nlines);
-  adjust_pointers_1 (old, new, num, arcs, narcs);
+  adjust_pointers_1 (old, newone, num, lines, nlines);
+  adjust_pointers_1 (old, newone, num, arcs, narcs);
 }
 
 static LineTypePtr
diff --git a/src/rats.c b/src/rats.c
index 3e9d6ee..24be309 100644
--- a/src/rats.c
+++ b/src/rats.c
@@ -72,7 +72,7 @@ RCSID ("$Id$");
  */
 static bool FindPad (char *, char *, ConnectionType *, bool);
 static bool ParseConnection (char *, char *, char *);
-static bool DrawShortestRats (NetListTypePtr, void (*)());
+static bool DrawShortestRats (NetListTypePtr, void (*)(register ConnectionTypePtr, register ConnectionTypePtr, register RouteStyleTypePtr));
 static bool GatherSubnets (NetListTypePtr, bool, bool);
 static bool CheckShorts (LibraryMenuTypePtr);
 static void TransferNet (NetListTypePtr, NetTypePtr, NetTypePtr);
@@ -235,7 +235,7 @@ ProcNetlist (LibraryTypePtr net_menu)
   SLayer = GetLayerGroupNumberByNumber (solder_silk_layer);
   CLayer = GetLayerGroupNumberByNumber (component_silk_layer);
 
-  Wantlist = calloc (1, sizeof (NetListType));
+  Wantlist = (NetListTypePtr)calloc (1, sizeof (NetListType));
   if (Wantlist)
     {
       ALLPIN_LOOP (PCB->Data);
@@ -360,8 +360,8 @@ TransferNet (NetListTypePtr Netl, NetTypePtr SourceNet, NetTypePtr DestNet)
 static bool
 CheckShorts (LibraryMenuTypePtr theNet)
 {
-  bool new, warn = false;
-  PointerListTypePtr generic = calloc (1, sizeof (PointerListType));
+  bool newone, warn = false;
+  PointerListTypePtr generic = (PointerListTypePtr)calloc (1, sizeof (PointerListType));
   /* the first connection was starting point so
    * the menu is always non-null
    */
@@ -382,17 +382,17 @@ CheckShorts (LibraryMenuTypePtr theNet)
 	    SET_FLAG (WARNFLAG, pin);
 	    continue;
 	  }
-	new = true;
+	newone = true;
 	POINTER_LOOP (generic);
 	{
 	  if (*ptr == pin->Spare)
 	    {
-	      new = false;
+	      newone = false;
 	      break;
 	    }
 	}
 	END_LOOP;
-	if (new)
+	if (newone)
 	  {
 	    menu = GetPointerMemory (generic);
 	    *menu = pin->Spare;
@@ -418,17 +418,17 @@ CheckShorts (LibraryMenuTypePtr theNet)
 	    SET_FLAG (WARNFLAG, pad);
 	    continue;
 	  }
-	new = true;
+	newone = true;
 	POINTER_LOOP (generic);
 	{
 	  if (*ptr == pad->Spare)
 	    {
-	      new = false;
+	      newone = false;
 	      break;
 	    }
 	}
 	END_LOOP;
-	if (new)
+	if (newone)
 	  {
 	    menu = GetPointerMemory (generic);
 	    *menu = pad->Spare;
@@ -559,7 +559,7 @@ GatherSubnets (NetListTypePtr Netl, bool NoWarn, bool AndRats)
  */
 
 static bool
-DrawShortestRats (NetListTypePtr Netl, void (*funcp) ())
+DrawShortestRats (NetListTypePtr Netl, void (*funcp) (register ConnectionTypePtr, register ConnectionTypePtr, register RouteStyleTypePtr))
 {
   RatTypePtr line;
   register float distance, temp;
@@ -728,7 +728,7 @@ DrawShortestRats (NetListTypePtr Netl, void (*funcp) ())
  *  if SelectedOnly is true, it will only draw rats to selected pins and pads
  */
 bool
-AddAllRats (bool SelectedOnly, void (*funcp) ())
+AddAllRats (bool SelectedOnly, void (*funcp) (register ConnectionTypePtr, register ConnectionTypePtr, register RouteStyleTypePtr))
 {
   NetListTypePtr Nets, Wantlist;
   NetTypePtr lonesome;
@@ -750,7 +750,7 @@ AddAllRats (bool SelectedOnly, void (*funcp) ())
   /* initialize finding engine */
   InitConnectionLookup ();
   SaveFindFlag (DRCFLAG);
-  Nets = calloc (1, sizeof (NetListType));
+  Nets = (NetListTypePtr)calloc (1, sizeof (NetListType));
   /* now we build another netlist (Nets) for each
    * net in Wantlist that shows how it actually looks now,
    * then fill in any missing connections with rat lines.
diff --git a/src/rats.h b/src/rats.h
index eb928d4..3d70f27 100644
--- a/src/rats.h
+++ b/src/rats.h
@@ -42,7 +42,7 @@ LibraryMenuTypePtr netname_to_netname (char *netname);
 RatTypePtr AddNet (void);
 char *ConnectionName (int, void *, void *);
 
-bool AddAllRats (bool, void (*)());
+bool AddAllRats (bool, void (*)(register ConnectionTypePtr, register ConnectionTypePtr, register RouteStyleTypePtr));
 bool SeekPad (LibraryEntryTypePtr, ConnectionTypePtr, bool);
 
 NetListTypePtr ProcNetlist (LibraryTypePtr);
diff --git a/src/report.c b/src/report.c
index f0668d9..9135e0d 100644
--- a/src/report.c
+++ b/src/report.c
@@ -77,7 +77,7 @@ ReportDrills (int argc, char **argv, int x, int y)
       total_drills += AllDrills->Drill[n].UnplatedCount;
     }
 
-  stringlist = malloc (512L + AllDrills->DrillN * 64L);
+  stringlist = (char *)malloc (512L + AllDrills->DrillN * 64L);
 
   /* Use tabs for formatting since can't count on a fixed font anymore.
      |  And even that probably isn't going to work in all cases.
diff --git a/src/rtree.c b/src/rtree.c
index f44672c..e2ef1ee 100644
--- a/src/rtree.c
+++ b/src/rtree.c
@@ -452,9 +452,9 @@ r_create_tree (const BoxType * boxlist[], int N, int manage)
   int i;
 
   assert (N >= 0);
-  rtree = calloc (1, sizeof (*rtree));
+  rtree = (rtree_t *)calloc (1, sizeof (*rtree));
   /* start with a single empty leaf node */
-  node = calloc (1, sizeof (*node));
+  node = (struct rtree_node *)calloc (1, sizeof (*node));
   node->flags.is_leaf = 1;
   node->parent = NULL;
   rtree->root = node;
@@ -761,7 +761,7 @@ find_clusters (struct rtree_node *node)
         break;
     }
   /* Now 'belong' has the partition map */
-  new_node = calloc (1, sizeof (*new_node));
+  new_node = (struct rtree_node *)calloc (1, sizeof (*new_node));
   new_node->parent = node->parent;
   new_node->flags.is_leaf = node->flags.is_leaf;
   clust_a = clust_b = 0;
@@ -834,7 +834,7 @@ split_node (struct rtree_node *node)
     {
       struct rtree_node *second;
 
-      second = calloc (1, sizeof (*second));
+      second = (struct rtree_node *)calloc (1, sizeof (*second));
       *second = *node;
       if (!second->flags.is_leaf)
         for (i = 0; i < M_SIZE; i++)
@@ -991,7 +991,7 @@ __r_insert_node (struct rtree_node *node, const BoxType * query,
       if (node->u.kids[0]->flags.is_leaf && i < M_SIZE)
         {
           struct rtree_node *new_node;
-          new_node = calloc (1, sizeof (*new_node));
+          new_node = (struct rtree_node *)calloc (1, sizeof (*new_node));
           new_node->parent = node;
           new_node->flags.is_leaf = true;
           node->u.kids[i] = new_node;
diff --git a/src/toporouter.c b/src/toporouter.c
index bfd494a..28a3764 100644
--- a/src/toporouter.c
+++ b/src/toporouter.c
@@ -66,9 +66,9 @@ toporouter_edge_init (toporouter_edge_t *edge)
 toporouter_edge_class_t * 
 toporouter_edge_class(void)
 {
-  static toporouter_edge_class_t *class = NULL;
+  static toporouter_edge_class_t *klass = NULL;
 
-  if (class == NULL) {
+  if (klass == NULL) {
     GtsObjectClassInfo constraint_info = {
       "toporouter_edge_t",
       sizeof (toporouter_edge_t),
@@ -78,10 +78,10 @@ toporouter_edge_class(void)
       (GtsArgSetFunc) NULL,
       (GtsArgGetFunc) NULL
     };
-    class = gts_object_class_new (GTS_OBJECT_CLASS (gts_edge_class ()), &constraint_info);
+    klass = (toporouter_edge_class_t *)gts_object_class_new (GTS_OBJECT_CLASS (gts_edge_class ()), &constraint_info);
   }
 
-  return class;
+  return klass;
 }
 
 static void 
@@ -96,9 +96,9 @@ toporouter_bbox_init (toporouter_bbox_t *box)
 toporouter_bbox_class_t * 
 toporouter_bbox_class(void)
 {
-  static toporouter_bbox_class_t *class = NULL;
+  static toporouter_bbox_class_t *klass = NULL;
 
-  if (class == NULL) {
+  if (klass == NULL) {
     GtsObjectClassInfo constraint_info = {
       "toporouter_bbox_t",
       sizeof (toporouter_bbox_t),
@@ -108,10 +108,10 @@ toporouter_bbox_class(void)
       (GtsArgSetFunc) NULL,
       (GtsArgGetFunc) NULL
     };
-    class = gts_object_class_new (GTS_OBJECT_CLASS (gts_bbox_class ()), &constraint_info);
+    klass = (toporouter_bbox_class_t *)gts_object_class_new (GTS_OBJECT_CLASS (gts_bbox_class ()), &constraint_info);
   }
 
-  return class;
+  return klass;
 }
 
 static void 
@@ -152,7 +152,7 @@ toporouter_vertex_class(void)
       (GtsArgSetFunc) NULL,
       (GtsArgGetFunc) NULL
     };
-    klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_vertex_class ()), &constraint_info);
+    klass = (toporouter_vertex_class_t *)gts_object_class_new (GTS_OBJECT_CLASS (gts_vertex_class ()), &constraint_info);
   }
 
   return klass;
@@ -186,7 +186,7 @@ toporouter_constraint_class(void)
       (GtsArgSetFunc) NULL,
       (GtsArgGetFunc) NULL
     };
-    klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_constraint_class ()), &constraint_info);
+    klass = (toporouter_constraint_class_t *)gts_object_class_new (GTS_OBJECT_CLASS (gts_constraint_class ()), &constraint_info);
   }
 
   return klass;
@@ -224,7 +224,7 @@ toporouter_arc_class(void)
       (GtsArgSetFunc) NULL,
       (GtsArgGetFunc) NULL
     };
-    klass = gts_object_class_new (GTS_OBJECT_CLASS (gts_constraint_class ()), &constraint_info);
+    klass = (toporouter_arc_class_t *)gts_object_class_new (GTS_OBJECT_CLASS (gts_constraint_class ()), &constraint_info);
   }
 
   return klass;
@@ -237,7 +237,7 @@ toporouter_output_init(int w, int h, char *filename)
 {
   drawing_context_t *dc;
 
-  dc = malloc(sizeof(drawing_context_t));
+  dc = (drawing_context_t *)malloc(sizeof(drawing_context_t));
 
   dc->iw = w;
   dc->ih = h;
@@ -1654,7 +1654,7 @@ delaunay_create_from_vertices(GList *vertices, GtsSurface **surface, GtsTriangle
  
   i = vertices;
   while (i) {
-    toporouter_vertex_t *v = TOPOROUTER_VERTEX(gts_delaunay_add_vertex (*surface, i->data, NULL));
+    toporouter_vertex_t *v = TOPOROUTER_VERTEX(gts_delaunay_add_vertex (*surface, (GtsVertex *)i->data, NULL));
     
     if(v) {
       printf("ERROR: vertex could not be added to CDT ");
@@ -1737,7 +1737,7 @@ insert_vertex(toporouter_t *r, toporouter_layer_t *l, gdouble x, gdouble y, topo
 
   i = l->vertices;
   while (i) {
-    v = i->data;
+    v = (GtsVertex *)i->data;
     if(v->p.x == x && v->p.y == y) {
       TOPOROUTER_VERTEX(v)->bbox = box;
       return v;
@@ -1769,7 +1769,7 @@ insert_constraint_edge(toporouter_t *r, toporouter_layer_t *l, gdouble x1, gdoub
 
   i = l->vertices;
   while (i) {
-    v = i->data;
+    v = (GtsVertex *)i->data;
     if(v->p.x == x1 && v->p.y == y1) 
       p[0] = v;
     if(v->p.x == x2 && v->p.y == y2) 
@@ -2262,8 +2262,8 @@ read_board_constraints(toporouter_t *r, toporouter_layer_t *l, int layer)
 gdouble 
 triangle_cost(GtsTriangle *t, gpointer *data){
 
-  gdouble *min_quality = data[0];
-  gdouble *max_area = data[1];
+  gdouble *min_quality = (gdouble *)data[0];
+  gdouble *max_area = (gdouble *)data[1];
   gdouble quality = gts_triangle_quality(t);
   gdouble area = gts_triangle_area(t);
   
@@ -2568,7 +2568,7 @@ check_cons_continuation:
     //v = i->data;
     //if(r->flags & TOPOROUTER_FLAG_DEBUG_CDTS) 
   //  fprintf(stderr, "\tadding vertex %f,%f\n", v->p.x, v->p.y);
-    toporouter_vertex_t *v = TOPOROUTER_VERTEX(gts_delaunay_add_vertex (l->surface, i->data, NULL));
+    toporouter_vertex_t *v = TOPOROUTER_VERTEX(gts_delaunay_add_vertex (l->surface, (GtsVertex *)i->data, NULL));
     if(v) {
       printf("conflict: "); print_vertex(v);
     }
@@ -2581,7 +2581,7 @@ check_cons_continuation:
     // toporouter_constraint_t *c1 = TOPOROUTER_CONSTRAINT(i->data);
     // printf("adding cons: "); print_constraint(c1);
 
-    GSList *conflicts = gts_delaunay_add_constraint (l->surface, i->data);
+    GSList *conflicts = gts_delaunay_add_constraint (l->surface, (GtsConstraint *)i->data);
     GSList *j = conflicts;
     while(j) {
       if(TOPOROUTER_IS_CONSTRAINT(j->data)) {
@@ -2739,7 +2739,7 @@ print_cluster(toporouter_cluster_t *c)
 toporouter_cluster_t *
 cluster_create(toporouter_t *r, toporouter_netlist_t *netlist)
 {
-  toporouter_cluster_t *c = malloc(sizeof(toporouter_cluster_t));
+  toporouter_cluster_t *c = (toporouter_cluster_t *)malloc(sizeof(toporouter_cluster_t));
 
   c->c = c->pc = netlist->clusters->len;
   g_ptr_array_add(netlist->clusters, c);
@@ -2784,7 +2784,7 @@ cluster_join_bbox(toporouter_cluster_t *cluster, toporouter_bbox_t *box)
 toporouter_netlist_t *
 netlist_create(toporouter_t *r, char *netlist, char *style)
 {
-  toporouter_netlist_t *nl = malloc(sizeof(toporouter_netlist_t));
+  toporouter_netlist_t *nl = (toporouter_netlist_t *)malloc(sizeof(toporouter_netlist_t));
   nl->netlist = netlist; 
   nl->style = style;
   nl->clusters = g_ptr_array_new();
@@ -2895,7 +2895,7 @@ import_geometry(toporouter_t *r)
   }
 #endif
   /* Allocate space for per layer struct */
-  cur_layer = r->layers = malloc(groupcount() * sizeof(toporouter_layer_t));
+  cur_layer = r->layers = (toporouter_layer_t *)malloc(groupcount() * sizeof(toporouter_layer_t));
 
   /* Foreach layer, read in pad vertices and constraints, and build CDT */
   for (group = 0; group < max_group; group++) {
@@ -4562,7 +4562,7 @@ space_edge(gpointer item, gpointer data)
 
   if(!edge_routing(e) || !g_list_length(edge_routing(e))) return 0;
 
-  forces = malloc(sizeof(double) * g_list_length(edge_routing(e)));
+  forces = (gdouble *)malloc(sizeof(double) * g_list_length(edge_routing(e)));
   
   for(guint j=0;j<100;j++) {
     guint k=0;
@@ -5987,7 +5987,7 @@ toporouter_serpintine_t *
 toporouter_serpintine_new(gdouble x, gdouble y, gdouble x0, gdouble y0, gdouble x1, gdouble y1, gpointer start, gdouble halfa, gdouble
     radius, guint nhalfcycles)
 {
-  toporouter_serpintine_t *serp = malloc(sizeof(toporouter_serpintine_t));
+  toporouter_serpintine_t *serp = (toporouter_serpintine_t *)malloc(sizeof(toporouter_serpintine_t));
   serp->x = x;
   serp->y = y;
   serp->x0 = x0;
@@ -6141,7 +6141,7 @@ check_arc_for_loops(gpointer t1, toporouter_arc_t *arc, gpointer t2)
 toporouter_rubberband_arc_t *
 new_rubberband_arc(toporouter_vertex_t *pathv, toporouter_vertex_t *arcv, gdouble r, gdouble d, gint wind, GList *list)
 {
-  toporouter_rubberband_arc_t *rba = malloc(sizeof(toporouter_rubberband_arc_t));
+  toporouter_rubberband_arc_t *rba = (toporouter_rubberband_arc_t *)malloc(sizeof(toporouter_rubberband_arc_t));
   rba->pathv = pathv;
   rba->arcv = arcv;
   rba->r = r;
@@ -6763,7 +6763,7 @@ path_speccut_restart:
 toporouter_oproute_t *
 oproute_rubberband(toporouter_t *r, GList *path)
 {
-  toporouter_oproute_t *oproute = malloc(sizeof(toporouter_oproute_t)); 
+  toporouter_oproute_t *oproute = (toporouter_oproute_t *)malloc(sizeof(toporouter_oproute_t)); 
 
   g_assert(path);
 
@@ -6832,7 +6832,7 @@ toporouter_export(toporouter_t *r)
 toporouter_route_t *
 routedata_create(void)
 {
-  toporouter_route_t *routedata = malloc(sizeof(toporouter_route_t));
+  toporouter_route_t *routedata = (toporouter_route_t *)malloc(sizeof(toporouter_route_t));
   routedata->netlist = NULL;
   routedata->alltemppoints = NULL;
   routedata->path = NULL;
@@ -7051,7 +7051,7 @@ init_cost_matrix(gdouble *m, guint n)
 toporouter_netscore_t *
 netscore_create(toporouter_t *r, toporouter_route_t *routedata, guint n, guint id)
 {
-  toporouter_netscore_t *netscore = malloc(sizeof(toporouter_netscore_t));
+  toporouter_netscore_t *netscore = (toporouter_netscore_t *)malloc(sizeof(toporouter_netscore_t));
   GList *path = route(r, routedata, 0);
   
   netscore->id = id;
@@ -7066,7 +7066,7 @@ netscore_create(toporouter_t *r, toporouter_route_t *routedata, guint n, guint i
     return NULL;
   }
 
-  netscore->pairwise_nodetour = malloc(n * sizeof(guint));
+  netscore->pairwise_nodetour = (guint *)malloc(n * sizeof(guint));
 
   for(guint i=0;i<n;i++) {
     netscore->pairwise_nodetour[i] = 0;
@@ -7349,7 +7349,7 @@ route_checkpoint(toporouter_route_t *route, toporouter_route_t *temproute)
   gint n = g_list_length(route->path);
 
   if(route->ppathindices) free(route->ppathindices);
-  route->ppathindices = malloc(sizeof(gint)*n);
+  route->ppathindices = (gint *)malloc(sizeof(gint)*n);
 
 //  n = 0;
   while(i) {
@@ -7834,7 +7834,7 @@ parse_arguments(toporouter_t *r, int argc, char **argv)
     if(sscanf(argv[i], "viacost=%d", &tempint)) {
       r->viacost = (double)tempint;
     }else if(sscanf(argv[i], "l%d", &tempint)) {
-      gdouble *layer = malloc(sizeof(gdouble));
+      gdouble *layer = (gdouble *)malloc(sizeof(gdouble));
       *layer = (double)tempint;
       r->keepoutlayers = g_list_prepend(r->keepoutlayers, layer);
     }
@@ -7843,7 +7843,7 @@ parse_arguments(toporouter_t *r, int argc, char **argv)
   for (guint group = 0; group < max_group; group++)
     for (i = 0; i < PCB->LayerGroups.Number[group]; i++) 
       if ((PCB->LayerGroups.Entries[group][i] < max_copper_layer) && !(PCB->Data->Layer[PCB->LayerGroups.Entries[group][i]].On)) {
-        gdouble *layer = malloc(sizeof(gdouble));
+        gdouble *layer = (gdouble *)malloc(sizeof(gdouble));
         *layer = (double)group;
         r->keepoutlayers = g_list_prepend(r->keepoutlayers, layer);
       }
@@ -7853,7 +7853,7 @@ parse_arguments(toporouter_t *r, int argc, char **argv)
 toporouter_t *
 toporouter_new(void) 
 {
-  toporouter_t *r = calloc(1, sizeof(toporouter_t));
+  toporouter_t *r = (toporouter_t *)calloc(1, sizeof(toporouter_t));
   time_t ltime; 
 
   gettimeofday(&r->starttime, NULL);  
diff --git a/src/undo.c b/src/undo.c
index 5226c53..b14e3ec 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -350,7 +350,7 @@ UndoChangeName (UndoListTypePtr Entry)
       if (TEST_FLAG (LOCKFLAG, (TextTypePtr) ptr3))
 	return (false);
       Entry->Data.ChangeName.Name =
-	(ChangeObjectName (type, ptr1, ptr2, ptr3,
+	(char *)(ChangeObjectName (type, ptr1, ptr2, ptr3,
 			   Entry->Data.ChangeName.Name));
       return (true);
     }
@@ -720,7 +720,7 @@ UndoRemovePoint (UndoListTypePtr Entry)
   /* lookup entry (polygon not point was saved) by it's ID */
   assert (Entry->Kind == POLYGON_TYPE);
   type =
-    SearchObjectByID (PCB->Data, (void *) &layer, (void *) &polygon, &ptr3,
+    SearchObjectByID (PCB->Data, (void **) &layer, (void **) &polygon, &ptr3,
 		      Entry->ID, Entry->Kind);
   switch (type)
     {
@@ -770,8 +770,8 @@ UndoInsertPoint (UndoListTypePtr Entry)
   assert (Entry->Kind == POLYGONPOINT_TYPE);
   /* lookup entry by it's ID */
   type =
-    SearchObjectByID (PCB->Data, (void *) &layer, (void *) &polygon,
-		      (void *) &pnt, Entry->ID, Entry->Kind);
+    SearchObjectByID (PCB->Data, (void **) &layer, (void **) &polygon,
+		      (void **) &pnt, Entry->ID, Entry->Kind);
   switch (type)
     {
     case POLYGONPOINT_TYPE:	/* removes an inserted polygon point */
@@ -833,8 +833,8 @@ UndoSwapCopiedObject (UndoListTypePtr Entry)
   if (type == NO_TYPE)
     return FALSE;
 
-  obj = ptr2;
-  obj2 = ptr2b;
+  obj = (AnyObjectType *)ptr2;
+  obj2 = (AnyObjectType *)ptr2b;
 
   swap_id = obj->ID;
   obj->ID = obj2->ID;
@@ -845,9 +845,9 @@ UndoSwapCopiedObject (UndoListTypePtr Entry)
   if (andDraw)
     DrawRecoveredObject (Entry->Kind, ptr1, ptr2, ptr3);
 
-  obj = MoveObjectToBuffer (PCB->Data, RemoveList, type, ptr1, ptr2, ptr3);
+  obj = (AnyObjectType *)MoveObjectToBuffer (PCB->Data, RemoveList, type, ptr1, ptr2, ptr3);
   if (Entry->Kind == POLYGON_TYPE)
-    InitClip (PCB->Data, ptr1b, (PolygonType *)obj);
+    InitClip (PCB->Data, (LayerTypePtr)ptr1b, (PolygonType *)obj);
   return (true);
 }
 
@@ -1370,7 +1370,7 @@ CopyObjectToUndoList (int undo_type, int Type, void *Ptr1, void *Ptr2, void *Ptr
     RemoveList = CreateNewBuffer ();
 
   undo = GetUndoSlot (undo_type, OBJECT_ID (Ptr2), Type);
-  copy = CopyObjectToBuffer (RemoveList, PCB->Data, Type, Ptr1, Ptr2, Ptr3);
+  copy = (AnyObjectType *)CopyObjectToBuffer (RemoveList, PCB->Data, Type, Ptr1, Ptr2, Ptr3);
   undo->Data.CopyID = copy->ID;
 }
 
@@ -1630,11 +1630,11 @@ AddNetlistLibToUndoList (LibraryTypePtr lib)
       undo->Data.NetlistChange.lib = lib;
 
       /* and what the old data is that we'll need to restore */
-      undo->Data.NetlistChange.old = malloc (sizeof (LibraryTypePtr));
+      undo->Data.NetlistChange.old = (LibraryTypePtr)malloc (sizeof (LibraryTypePtr));
       old = undo->Data.NetlistChange.old;
       old->MenuN = lib->MenuN;
       old->MenuMax = lib->MenuMax;
-      old->Menu = malloc (old->MenuMax * sizeof (LibraryMenuType));
+      old->Menu = (LibraryMenuTypePtr)malloc (old->MenuMax * sizeof (LibraryMenuType));
       if (old->Menu == NULL)
 	{
 	  fprintf (stderr, "malloc() failed in %s\n", __FUNCTION__);
@@ -1658,7 +1658,7 @@ AddNetlistLibToUndoList (LibraryTypePtr lib)
 
       
 	  old->Menu[i].Entry = 
-	    malloc (old->Menu[i].EntryMax * sizeof (LibraryEntryType));
+	    (LibraryEntryTypePtr)malloc (old->Menu[i].EntryMax * sizeof (LibraryEntryType));
 	  if (old->Menu[i].Entry == NULL)
 	    {
 	      fprintf (stderr, "malloc() failed in %s\n", __FUNCTION__);
diff --git a/src/vector.c b/src/vector.c
index 169afd3..c039b89 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -91,7 +91,7 @@ vector_create ()
 {
   vector_t *vector;
   /* okay, create empty vector */
-  vector = calloc (1, sizeof (*vector));
+  vector = (vector_t *)calloc (1, sizeof (*vector));
   assert (vector);
   assert (__vector_is_good (vector));
   return vector;
@@ -189,7 +189,7 @@ vector_insert_many (vector_t * vector, int N,
   if (vector->size + count > vector->max)
     {
       vector->max = MAX (32, MAX (vector->size + count, vector->max * 2));
-      vector->element = realloc (vector->element,
+      vector->element = (void **)realloc (vector->element,
 				 vector->max * sizeof (*vector->element));
     }
   memmove (vector->element + N + count, vector->element + N,
@@ -202,15 +202,15 @@ vector_insert_many (vector_t * vector, int N,
 vector_t *
 vector_duplicate (vector_t * orig)
 {
-  vector_t * new = vector_create();
+  vector_t * newone = vector_create();
   if (!orig)
-    return new;
-  new->element = malloc (orig->max * sizeof (*orig->element));
-  new->max = orig->max;
-  new->size = orig->size;
-  memcpy (new->element, orig->element, orig->size * sizeof (vector_element_t));
-  assert (__vector_is_good (new));
-  return new;
+    return newone;
+  newone->element = (void **)malloc (orig->max * sizeof (*orig->element));
+  newone->max = orig->max;
+  newone->size = orig->size;
+  memcpy (newone->element, orig->element, orig->size * sizeof (vector_element_t));
+  assert (__vector_is_good (newone));
+  return newone;
 }
 
 /* return and delete the *last* element of vector */
diff --git a/src/vendor.c b/src/vendor.c
index a296aa1..5b7f5eb 100644
--- a/src/vendor.c
+++ b/src/vendor.c
@@ -321,7 +321,7 @@ ActionLoadVendorFrom (int argc, char **argv, int x, int y)
     }
 
   /* figure out the vendor name, if specified */
-  vendor_name = UNKNOWN (resource_value (res, "vendor"));
+  vendor_name = (char *)UNKNOWN (resource_value (res, "vendor"));
 
   /* figure out the units, if specified */
   sval = resource_value (res, "units");
@@ -701,7 +701,7 @@ add_to_drills (char *sval)
 
   /* increment the count and make sure we have memory */
   n_vendor_drills++;
-  if ((vendor_drills = realloc (vendor_drills,
+  if ((vendor_drills = (int *)realloc (vendor_drills,
 				n_vendor_drills * sizeof (int))) == NULL)
     {
       fprintf (stderr, "realloc() failed to allocate %ld bytes\n",




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs