numeric_limits min max methods conflict with windef.h min max macr

numeric_limits min max methods conflict with windef.h min max macr

Post by Sm9obiBQLi » Sat, 11 Feb 2006 22:11:30


The min and max macros defined in <windef.h> conflicts with the min and max
methods of numeric_limits declared <limits>.

This can happen if <windows.h> is included. Thus, the numeric_limits
examples provided by Microsoft won't work under this condition, e.g.

std::numeric_limits<char>::min()

won't compile correctly.

See:
http://www.yqcomputer.com/ (STL_Sample).asp

The solution is to wrap the full method name in parentheses, e.g.
(std::numeric_limits<char>::min)()

--
jpe
 
 
 

numeric_limits min max methods conflict with windef.h min max macr

Post by Pete Becke » Sat, 11 Feb 2006 23:01:55


Or to get rid of the macros by defining a macro named NOMINMAX before
you include <windows.h>.

--

Pete Becker
Dinkumware, Ltd. ( http://www.yqcomputer.com/ )

 
 
 

numeric_limits min max methods conflict with windef.h min max macr

Post by Ulrich Eck » Sat, 11 Feb 2006 23:12:14


[...]

Another way is to "#define NOMINMAX". However, some ATL headers depend on
these broken macros so you might have to "#include <algorithm>" and "using
std::min and std::max" or patch those headers.

Uli