compatibility: fix compiler warning about size_t on some system
authorJean-Sebastien Gelinas <calestar@gmail.com>
Fri, 7 Jan 2011 05:52:33 +0000 (00:52 -0500)
committerJean-Sebastien Gelinas <calestar@gmail.com>
Fri, 7 Jan 2011 05:52:33 +0000 (00:52 -0500)
Signed-off-by: Jean-Sebastien Gelinas <calestar@gmail.com>

clib/gc.c

index de0a723..8f65664 100644 (file)
--- a/clib/gc.c
+++ b/clib/gc.c
@@ -194,7 +194,13 @@ static void GC_prepare_heap_size(size_t size) {
 }
 
 void Nit_gc_print_usage(void) {
-       printf("GC: Size %d usage %d (%.2f%%)\n", gc_heap_size, gc_used_size, 100.0*gc_used_size/gc_heap_size);
+#if __STDC_VERSION >= 199901L
+       /* If we are compiling with standard C99 or more recent, we can use %zu. */
+       printf("GC: Size %zu usage %zu (%.2f%%)\n", gc_heap_size, gc_used_size, 100.0*gc_used_size/gc_heap_size);
+#else
+       /* We are not compiling with a standard that allows us to use %zu, let's cast the two unsigned integers into the biggest we can !*/
+       printf("GC: Size %lu usage %lu (%.2f%%)\n", (unsigned long)gc_heap_size, (unsigned long)gc_used_size, 100.0*gc_used_size/gc_heap_size);
+#endif
 }
 
 /** Enlarge the heap and collect dead objects. Can also shrink the heap.