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

Christophe Fergeau cfergeau at redhat.com
Thu Mar 1 03:56:31 PST 2012


On Thu, Mar 01, 2012 at 01:47:18PM +0200, Alon Levy wrote:
> On Thu, Mar 01, 2012 at 11:17:39AM +0100, Christophe Fergeau wrote:
> > ---
> >  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"
> >  
> 
> Instead:
> 
> #ifdef __GNUC__
> using std::min;
> using std::max;
> #endif

Yes, thanks, I avoid "using" use so much that I don't think about it when
it would make sense :-/

Christophe
> 
> > +
> > +/* 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
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20120301/3d47b207/attachment.pgp>


More information about the Spice-devel mailing list