Topic: STL Implementation........
Author: Allan Simpson <en31@dial.pipex.com>
Date: 1997/08/25 Raw View
Although I have used templates in my code I recently decided to use
SGI's implementation of the STL.
.....but I can't get anything to compile. The problem seems to be
a clash between the STL's templatized ( is that the right word ? is it
even a word ? ) min and max functions and the standard min and max
macros.
I though STL implementations were supposed to be in a seperate
namespace ?
Any pointers appreciated.........
Allan
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Ross Smith <ross.smith@nz.eds.com>
Date: 1997/08/26 Raw View
Allan Simpson wrote:
>
> Although I have used templates in my code I recently decided to use
> SGI's implementation of the STL.
Good plan :-)
> .....but I can't get anything to compile. The problem seems to be
> a clash between the STL's templatized ( is that the right word ? is it
> even a word ? ) min and max functions and the standard min and max
> macros.
The STL's min and max functions *are* the standard ones. There have
never been any standard min and max macros (as distinct from functions)
in C or C++.
What you're probably having trouble with are the min and max macros that
are provided by the Windows headers. (These are not standard in any
sense other than the "Wintel is a de facto standard" one.) This is a
common problem when using the STL in conjunction with Windows, and the
fix is trivial: just #define NOMINMAX before including any Windows
headers.
If it isn't the Windows headers, you may have a compiler that
"helpfully" defines these macros in one of its nominally standard
headers (they're often to be found lurking in stdlib.h). If there's no
documented way to disable these (try setting your compiler in maximum
ISO/ANSI compatibility mode), congratulations, you have a real live
Compiler Bug in captivity. Complain to your compiler vendor, and edit
the relevant header to remove them.
> I though STL implementations were supposed to be in a seperate
> namespace ?
According to the draft C++ standard, the entire standard library is
supposed to be in namespace std. However, the SGI implementation of the
STL (which is *not* the same thing as the C++ standard library) doesn't
use namespaces. If you want to, you can put:
namespace std {
#include <some_stl_header.h>
}
around each STL header. (This wouldn't work on headers that declare
things that are defined in object files, because you'd get link errors,
but the SGI STL is built entirely of header files.)
Regardless of whether the STL is in a namespace or not, though, it won't
fix your problem with min/max macros, because macros don't respect
namespaces. (This is one of the many reasons why macros are frowned upon
in these enlightened days.) The only way to fix the min/max problem is
to disable the macros, as described above.
--
Ross Smith ............................. <mailto:ross.smith@nz.eds.com>
Internet and New Media, EDS (New Zealand) Ltd., Wellington, New Zealand
"The first thing we do, let's kill all the language lawyers."
-- Henry VI Part II, by W. Shakespeare;
additional dialogue by B. Stroustrup
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: Yonat Sharon <yonat@usa.net>
Date: 1997/08/27 Raw View
Allan Simpson wrote:
> Although I have used templates in my code I recently decided to use
> SGI's implementation of the STL.
>
> .....but I can't get anything to compile. The problem seems to be
> a clash between the STL's templatized ( is that the right word ? is it
> even a word ? ) min and max functions and the standard min and max
> macros.
Try the portable version of SGI STL from:
http://www.ipmce.su/~fbp/stl/
There is also a version ported specifically for MS Visual C++ 5.0:
http://www.sirius.com/~ouchida/
Hope this helps,
Yonat.
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]