util/ansi-print.cc: Use fallback implementation for lround on MSVC
authorChun-wei Fan <fanchunwei@src.gnome.org>
Mon, 3 Jun 2013 09:55:29 +0000 (17:55 +0800)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 3 Jun 2013 22:50:26 +0000 (18:50 -0400)
Unfortuately Visual Studio (still) does not support the C99 function
lround, so provide a fallback implementation for it.

util/ansi-print.cc

index 873bee8..e166c91 100644 (file)
 #include <unistd.h> /* for isatty() */
 #endif
 
+#ifdef _MSC_VER
+static inline long int
+lround (double x)
+{
+  if (x >= 0)
+    return floor (x + 0.5);
+  else
+    return ceil (x - 0.5);
+}
+#endif
+
 #define MIN(a,b) ((a) < (b) ? (a) : (b))
 
 #define CELL_W 8