8151998: VS2010 ThemeReader.cpp(758) : error C3861: 'round': identifier not found
authoralexsch
Thu, 24 Mar 2016 13:27:44 -0700
changeset 36913 bac425909021
parent 36912 fe8c68b091aa
child 36914 f790ef973830
8151998: VS2010 ThemeReader.cpp(758) : error C3861: 'round': identifier not found Reviewed-by: serb, ssadetsky
jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp
jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp
--- a/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp	Thu Mar 24 20:28:53 2016 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/ThemeReader.cpp	Thu Mar 24 13:27:44 2016 -0700
@@ -70,6 +70,11 @@
 #define TMT_TRANSPARENT 2201
 #endif // _UXTHEME_H_
 
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#  define ROUND_TO_INT(num)    ((int) round(num))
+#else
+#  define ROUND_TO_INT(num)    ((int) floor((num) + 0.5))
+#endif
 
 #define ALPHA_MASK 0xff000000
 #define RED_MASK 0xff0000
@@ -755,11 +760,11 @@
 
     if (dpiX !=0 && dpiX != 96) {
         float invScaleX = 96.0f / dpiX;
-        size->cx = (int)round(size->cx * invScaleX);
+        size->cx = ROUND_TO_INT(size->cx * invScaleX);
     }
     if (dpiY != 0 && dpiY != 96) {
         float invScaleY = 96.0f / dpiY;
-        size->cy = (int)round(size->cy * invScaleY);
+        size->cy = ROUND_TO_INT(size->cy * invScaleY);
     }
     ::ReleaseDC(hWnd, hDC);
 }
--- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp	Thu Mar 24 20:28:53 2016 +0300
+++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DesktopProperties.cpp	Thu Mar 24 13:27:44 2016 -0700
@@ -37,6 +37,12 @@
 
 #include "math.h"
 
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+#  define ROUND_TO_INT(num)    ((int) round(num))
+#else
+#  define ROUND_TO_INT(num)    ((int) floor((num) + 0.5))
+#endif
+
 // WDesktopProperties fields
 jfieldID AwtDesktopProperties::pDataID = 0;
 jmethodID AwtDesktopProperties::setBooleanPropertyID = 0;
@@ -92,7 +98,7 @@
 }
 
 int rescale(int value, float invScale){
-    return invScale == 1.0f ? value : (int)round(value * invScale);
+    return invScale == 1.0f ? value : ROUND_TO_INT(value * invScale);
 }
 
 void AwtDesktopProperties::GetSystemProperties() {