[Nel] matrix.cpp std::min/max problems?
Bryce Harrington
bryce@neptune.net
Fri, 10 Nov 2000 03:43:08 -0800 (PST)
Heh, well sorry but that's MS for ya...
As I recall, if you go MFC-free this particular issue will vanish.
However there are other insidious STL bugs with Visual C++.
If in fact you are using MFC, I would urge you to cease doing so at the
earliest convenience. Not only for portability reasons (MFC *ain't*
portable, especially not backwards-wise) but also because it is a poor
architecture for GUI development, and is not really in the GPL spirit of
things. If you intend to conduct your development openly as a net
project, then crossplatformness is going to be especially treasured by
you. There are many options for crossplatform GUI libs. Let me know if
you'd like to discuss this more. My two preferred libs are wxWindows
(good for OS-matching widgets for editors and similar), or libuta (SDL
compatible and skinnable). Mozilla has another cross platform GUI lib
but I've not used it in its current incarnation so don't know whether
it's usable independently of Mozilla.
FWIW, I always stick this boilerplate code in any file that uses STL
that I'd like to compile with MSVC 4.2:
#ifdef _MSC_VER
// Fix broken STL implementation in MSVC 4.2
// Include files (for MSVC)
#pragma warning(disable: 4786) // Kludge to get around bug in MSVC 4.2
#pragma warning(disable: 4788) // See above
#endif
I think you may be stuck including your own max/min template functions.
That's a pretty minor thing compared with some of the patches you may
have to make to work around some of the other issues (especially if you
want to support pre-6.0 MSVC).
Ultimately, you're going to want to trim down use of STL anyway, so you
can recover the performance loss. We still use STL at WorldForge, for
instance, but some simple tests show that hand coded, non-templated map
and list classes provide some modest performance gains, and some day
when we're down to squeezing out the last bits of performance, we'll
probably be pulling STL out ourselves.
Bryce
On Fri, 10 Nov 2000, Vianney Lecroart wrote:
> > The VC++/STL min/max problem is pretty well known, and is a result of a
> > very buggy STL implementation in VC++, and some lawsuits.
> >
> > Simple answer: Define NOMINMAX in your Build Settings
>
> ok, this define disables the macro min & max, it's same behavior as doing
> #undef min #undef max
> but I search min in the VC include directory and subdirectory and there s
> *no* min
> definition in the STL (no template min) so we have to define our own min &
> max
> template function in our code... no very cool...
--
Bryce Harrington
bryce @ neptune.net