Support long longs in const and enum in template-hsc.h
authorIan Lynagh <igloo@earth.li>
Tue, 24 Apr 2012 21:04:12 +0000 (22:04 +0100)
committerIan Lynagh <igloo@earth.li>
Tue, 24 Apr 2012 21:04:12 +0000 (22:04 +0100)
This is needed to support pointer-sized values on Win64.

template-hsc.h

index 6f47168..b27faee 100644 (file)
@@ -31,11 +31,11 @@ void *hsc_stdout(void);
     hsc_printf ("{-# LINE %d \"%s\" #-}\n", line, file);
 #endif
 
-#define hsc_const(x...)                     \
-    if ((x) < 0)                            \
-        hsc_printf ("%ld", (long)(x));      \
-    else                                    \
-        hsc_printf ("%lu", (unsigned long)(x));
+#define hsc_const(x...)                               \
+    if ((x) < 0)                                      \
+        hsc_printf ("%lld", (long long)(x));          \
+    else                                              \
+        hsc_printf ("%llu", (unsigned long long)(x));
 
 #define hsc_const_str(x...)                                       \
     {                                                             \
@@ -85,15 +85,15 @@ void *hsc_stdout(void);
 #define hsc_size(t...) \
     hsc_printf("(%ld)", (long) sizeof(t));
 
-#define hsc_enum(t, f, print_name, x)         \
-    print_name;                               \
-    hsc_printf (" :: %s\n", #t);                  \
-    print_name;                               \
-    hsc_printf (" = %s ", #f);                    \
-    if ((x) < 0)                              \
-        hsc_printf ("(%ld)\n", (long)(x));        \
-    else                                      \
-        hsc_printf ("%lu\n", (unsigned long)(x));
+#define hsc_enum(t, f, print_name, x)                   \
+    print_name;                                         \
+    hsc_printf (" :: %s\n", #t);                        \
+    print_name;                                         \
+    hsc_printf (" = %s ", #f);                          \
+    if ((x) < 0)                                        \
+        hsc_printf ("(%lld)\n", (long long)(x));        \
+    else                                                \
+        hsc_printf ("%llu\n", (unsigned long long)(x));
 
 #define hsc_haskellize(x...)                                       \
     {                                                              \