[m-rev.] diff: fix another compilation problem with Visual C

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Jul 13 11:21:51 AEST 2011


Branches: main, 11.07

Fix a another Visual C runtime compilation problem.

runtime/mercury_heap_profile.c:
 	Avoid arithmetic with void pointers.
 	(That's a GNU extension.)

Julien.

Index: runtime/mercury_heap_profile.c
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/runtime/mercury_heap_profile.c,v
retrieving revision 1.8
diff -u -r1.8 mercury_heap_profile.c
--- runtime/mercury_heap_profile.c	20 May 2011 04:16:54 -0000	1.8
+++ runtime/mercury_heap_profile.c	13 Jul 2011 01:20:40 -0000
@@ -72,7 +72,7 @@
      const MR_Code *proc, const char *type_name, int size)
  {
      MR_bool             found;
-    int                 diff;
+    MR_Integer          diff;
      MR_memprof_record   **node_addr;
      MR_memprof_record   *node;

@@ -83,7 +83,11 @@
      node_addr = &table->root;
      if (proc != NULL) {
          while ((node = *node_addr) != NULL) {
-            diff = proc - node->proc;
+            /*
+            ** The casts to MR_Integer are so that we work with C compilers
+            ** that do not support arithmetic with void pointers.
+            */
+            diff = (MR_Integer)proc - (MR_Integer)node->proc;
              if (diff < 0) {
                  node_addr = &node->left;
              } else if (diff > 0) {

--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list