Building problems 21.5.16 with MSVC6

Reini Urban <[email protected]> Sat, 31 Jan 2004 21:07:04 +0100
Newsgroups gmane.emacs.xemacs.windows
Message-ID <[email protected]>
There are thousands of missing __cdecl warnings. (ignorable)

qsort + bsearch calls don't compile with msvc6. generally most function 
with functions as params miss the with return type cast.
vc needs a (int *) cast on the 4. qsort param, as well as on the bsearch 
call.

I managed to fix the lib-src/ files, but needed a #define _MSC_VER 
workaround for the wrong qsort method in sorted-doc.c

patch against 21.5.16 release attached.

BTW: I'm waiting for some months now for an updated windows netinstaller 
kit for the latest release version 21.4.14. anybody?
For cygwin I saw some announce on the cygwin-apps list, but no 
ready-to-go yet.
-- 
Reini Urban
http://xarch.tu-graz.ac.at/home/rurban/
xemacs-21.5.16-msvc6.patch (text/plain, 5.6 KB)
--- xemacs-21.5.16/lib-src/ChangeLog~	2003-09-26 00:33:36.000000000 +0100
+++ xemacs-21.5.16/lib-src/ChangeLog	2004-01-31 21:05:39.156250000 +0100
@@ -1,3 +1,8 @@
+2004-01-31  Reini Urban <[email protected]>
+
+	* sorted-doc.c: provide correct type casts for functional 
+	arguments (qsort), needed for MSVC6
+	
 2003-09-26  Steve Youngs  <[email protected]>
 
 	* XEmacs 21.5.16 "celeriac" is released.
--- xemacs-21.5.16/lib-src/sorted-doc.c~	2001-06-10 11:42:18.000000000 +0100
+++ xemacs-21.5.16/lib-src/sorted-doc.c	2004-01-31 18:27:39.406250000 +0100
@@ -79,6 +79,14 @@
 
 /* Comparison function for qsort to call.  */
 
+#ifdef _MSC_VER
+int cmpdoc (const void *a, const void *b)
+{
+  register int val = strcmp ((*(DOCSTR**)a)->name, (*(DOCSTR**)b)->name);
+  if (val) return val;
+  return (*(DOCSTR**)a)->type - (*(DOCSTR**)b)->type;
+}
+#else
 static int
 cmpdoc (DOCSTR **a, DOCSTR **b)
 {
@@ -86,7 +94,7 @@
   if (val) return val;
   return (*a)->type - (*b)->type;
 }
-
+#endif
 
 enum state
 {
@@ -196,9 +204,12 @@
       array[i++] = dp;
 
     /* sort the array by name; within each name, by type */
-
+#ifdef _MSC_VER
+    qsort( (void *)array, cnt, sizeof (DOCSTR*), (int *) cmpdoc);
+#else
     qsort ((char*)array, cnt, sizeof (DOCSTR*),
 	   (int (*)(const void *, const void *)) cmpdoc);
+#endif
 
     /* write the output header */
 
--- xemacs-21.5.16/src/ChangeLog~	2003-09-26 00:33:39.000000000 +0100
+++ xemacs-21.5.16/src/ChangeLog	2004-01-31 21:05:03.078125000 +0100
@@ -1,3 +1,8 @@
+2004-01-31  Reini Urban <[email protected]>
+
+	* dired-msw.c, extents.c, glyphs-eimage.c, process-nt.c: provide correct 
+	type casts for functional arguments, needed for MSVC6
+	
 2003-09-26  Steve Youngs  <[email protected]>
 
 	* XEmacs 21.5.16 "celeriac" is released.
--- xemacs-21.5.16/src/dired-msw.c~	2003-01-13 09:46:26.000000000 +0100
+++ xemacs-21.5.16/src/dired-msw.c	2004-01-31 18:30:53.859375000 +0100
@@ -180,7 +180,7 @@
   mswindows_sort_method = sort_by;
   mswindows_reverse_sort = reverse;
   qsort (Dynarr_atp (files, 0), Dynarr_length (files),
-	 sizeof (Win32_file), mswindows_ls_sort_fcn);
+	 sizeof (Win32_file), (int *) mswindows_ls_sort_fcn);
 }
 
 static Win32_file_dynarr *
--- xemacs-21.5.16/src/extents.c~	2003-02-13 18:06:40.000000000 +0100
+++ xemacs-21.5.16/src/extents.c	2004-01-31 18:36:22.593750000 +0100
@@ -2819,7 +2819,7 @@
        of extents overlapping the same spot.  This will result in
        catastrophic behavior if we use the bubble sort above. */
     qsort (Dynarr_atp (extarr, 0), Dynarr_length (extarr),
-	   sizeof (EXTENT), extent_priority_sort_function);
+	   sizeof (EXTENT), (int *) extent_priority_sort_function);
 }
 
 /* If PROP is the `invisible' property of an extent,
@@ -3726,15 +3726,15 @@
       extent_properties (XEXTENT (parent), newprops);
 
     qsort (Dynarr_atp (oldprops, 0), Dynarr_length (oldprops),
-	   sizeof (Lisp_Object_pair), compare_key_value_pairs);
+	   sizeof (Lisp_Object_pair), (int *)compare_key_value_pairs);
     qsort (Dynarr_atp (newprops, 0), Dynarr_length (newprops),
-	   sizeof (Lisp_Object_pair), compare_key_value_pairs);
+	   sizeof (Lisp_Object_pair), (int *)compare_key_value_pairs);
     orignewlength = Dynarr_length (newprops);
     for (i = 0; i < Dynarr_length (oldprops); i++)
       {
 	if (!bsearch (Dynarr_atp (oldprops, i), Dynarr_atp (newprops, 0),
 		      Dynarr_length (newprops), sizeof (Lisp_Object_pair),
-		      compare_key_value_pairs))
+		      (int *)compare_key_value_pairs))
 	  {
 	    Lisp_Object_pair new;
 	    new.key = Dynarr_at (oldprops, i).key;
@@ -3748,7 +3748,7 @@
 						   Dynarr_atp (oldprops, 0),
 						   Dynarr_length (oldprops), 
 						   sizeof (Lisp_Object_pair),
-						   compare_key_value_pairs))
+						   (int *)compare_key_value_pairs))
 	  {
 	    Lisp_Object_pair new;
 	    new.key = Dynarr_at (newprops, i).key;
@@ -3757,9 +3757,9 @@
 	  }
       }
     qsort (Dynarr_atp (oldprops, 0), Dynarr_length (oldprops),
-	   sizeof (Lisp_Object_pair), compare_key_value_pairs);
+	   sizeof (Lisp_Object_pair), (int *)compare_key_value_pairs);
     qsort (Dynarr_atp (newprops, 0), Dynarr_length (newprops),
-	   sizeof (Lisp_Object_pair), compare_key_value_pairs);
+	   sizeof (Lisp_Object_pair), (int *)compare_key_value_pairs);
     for (i = 0; i < Dynarr_length (oldprops); i++)
       {
 	assert (EQ (Dynarr_at (oldprops, i).key, Dynarr_at (newprops, i).key));
--- xemacs-21.5.16/src/glyphs-eimage.c~	2002-06-20 22:18:33.000000000 +0100
+++ xemacs-21.5.16/src/glyphs-eimage.c	2004-01-31 20:47:56.718750000 +0100
@@ -864,7 +864,7 @@
 
   /* Initialize all PNG structures */
   png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, (void*)&png_err_stct,
-				    png_error_func, png_warning_func);
+				    (png_error_ptr) png_error_func, (png_error_ptr) png_warning_func);
   if (!png_ptr)
     signal_image_error ("Error obtaining memory for png_read", instantiator);
   info_ptr = png_create_info_struct (png_ptr);
@@ -912,7 +912,7 @@
     tbr.bytes = bytes;
     tbr.len = len;
     tbr.index = 0;
-    png_set_read_fn (png_ptr,(void *) &tbr, png_read_from_memory);
+    png_set_read_fn ((png_structp) png_ptr,(void *) &tbr, (png_rw_ptr) png_read_from_memory);
   }
 
   png_read_info (png_ptr, info_ptr);
--- xemacs-21.5.16/src/process-nt.c~	2003-01-13 09:46:45.000000000 +0100
+++ xemacs-21.5.16/src/process-nt.c	2004-01-31 20:37:36.546875000 +0100
@@ -914,7 +914,7 @@
 
     /* Sort the environment variables */
     new_length = new_env - env;
-    qsort (env, new_length, sizeof (Ibyte *), mswindows_compare_env);
+    qsort (env, new_length, sizeof (Ibyte *), (int *)mswindows_compare_env);
 
     {
       DECLARE_EISTRING (envout);