Boost logo

Boost :

From: Eric Niebler (eric_at_[hidden])
Date: 2003-12-29 16:50:43

I just ran into an issue ralated to the use of Boost and MFC on Win32.
The MFC file afxtempl.h relies on the max macro, which has been
#undef'ed by config/platform/win32.hpp. The following program, compiled
with vc7.1, demonstrates the problem.

#include "boost/utility.hpp"
#include <afxtempl.h>

int main()
     CArray<int> array;
     return 0;

f:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\atlmfc\include\afxtempl.h(398) : error C2668: 'std::max' :
ambiguous call to overloaded function
could be 'long std::max(long,long)'
         f:\boost\boost-1.30.2\boost\config\platform\win32.hpp(66): or
      'long double std::max(long double,long double)'
         while trying to match the argument list '(INT_PTR, INT_PTR)'
         f:\Program Files\Microsoft Visual Studio .NET
2003\Vc7\atlmfc\include\atlsimpstr.h(421) : while compiling
class-template member function 'void CArray<TYPE>::SetSize(INT_PTR,INT_PTR)'
         f:\src\scratch_vc7\main.cpp(9) : see reference to class
template instantiation 'CArray<TYPE>' being compiled

It seems extremely unwise to be undef'ing min and max. Evil though they
are, many Win32 platform headers (and users' headers!) depend on them,
and there is simply no way to write a template or set of overloads that
behave exactly as the macros do.

Eric Niebler
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at