[Spice-devel] [PATCH 05/20] mingw: use explicit std:: namespace for min/max

Christophe Fergeau cfergeau at redhat.com
Thu Mar 1 02:17:39 PST 2012


---
 vdagent/desktop_layout.cpp |   34 ++++++++++++++++++++++++++++++----
 1 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/vdagent/desktop_layout.cpp b/vdagent/desktop_layout.cpp
index f880fd3..b599aa3 100644
--- a/vdagent/desktop_layout.cpp
+++ b/vdagent/desktop_layout.cpp
@@ -18,6 +18,32 @@
 #include "desktop_layout.h"
 #include "vdlog.h"
 
+
+/* A bit ugly, VC++ doesn't have std::min but has min while
+ * mingw32 doesn't have min but has std::min
+ */
+#ifdef __GNUC__
+static LONG my_min(LONG lhs, LONG rhs)
+{
+    return std::min(lhs, rhs);
+}
+
+static LONG my_max(LONG lhs, LONG rhs)
+{
+    return std::max(lhs, rhs);
+}
+#else
+static LONG my_min(LONG lhs, LONG rhs)
+{
+    return min(lhs, rhs);
+}
+
+static LONG my_max(LONG lhs, LONG rhs)
+{
+    return max(lhs, rhs);
+}
+#endif
+
 void DisplayMode::set_res(DWORD width, DWORD height, DWORD depth)
 {
     _width = width;
@@ -150,10 +176,10 @@ void DesktopLayout::normalize_displays_pos()
     for (iter = _displays.begin(); iter != _displays.end(); iter++) {
         mode = *iter;
         if (mode->_attached) {
-            min_x = min(min_x, mode->_pos_x);
-            min_y = min(min_y, mode->_pos_y);
-            max_x = max(max_x, mode->_pos_x + (LONG)mode->_width);
-            max_y = max(max_y, mode->_pos_y + (LONG)mode->_height);
+            min_x = my_min(min_x, mode->_pos_x);
+            min_y = my_min(min_y, mode->_pos_y);
+            max_x = my_max(max_x, mode->_pos_x + (LONG)mode->_width);
+            max_y = my_max(max_y, mode->_pos_y + (LONG)mode->_height);
         }
     }
     if (min_x || min_y) {
-- 
1.7.7.6



More information about the Spice-devel mailing list