Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2003-12-30 06:25:46

> 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;
> array.SetSize(3);
> return 0;
> }
> 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.

I agree - but there is plenty of boost code that relies on std::min and
std::max *not* being macros - were we not to do this then a fair portion of
Boost would just stop working :-(

There is BTW a trivial fix for your problem: include the windows headers
*before* any Boost ones.

However, there is also a bug in our workaround - we haven't include
<algorithm> to get the template min/max functions as well as the additional
overloads that we add in the workaround, and it's this that is the cause of
the error in this case, I'm committing a revised win32.hpp which will now
compile the sample you posted (or will be as soon as the config regression
tests complete).


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