From: <dan...@ya...> - 2003-03-03 09:01:39
|
--- Wu Yongwei <ad...@ne...> wrote: > The following simple code segments will cause error messages: > > #include <vector> > #include <windows.h> > #include <string> > > int main() > { > return 0; > } > > g++ test.cpp > > In file included from D:/mingw-gcc3/include/c++/3.2.2/string:57, > from test.cpp:3: > D:/mingw-gcc3/include/c++/3.2.2/bits/basic_string.tcc: In member function > `_Alloc::size_type std::basic_string<_CharT, _Traits, > _Alloc>::rfind(const > _CharT*, _Alloc::size_type, _Alloc::size_type) const': > D:/mingw-gcc3/include/c++/3.2.2/bits/basic_string.tcc:712: parse error > before `(' token > > The reason seems to be the macro definition of min in windef.h and the > use of "std::" in line 712 of basic_string.tcc. The simplest cure seems > to be removing "std::" from line 712 of basic_string.tcc (). Another > way is to define NOMINMAX before entering windows.h. Yet another way is to always include <windows.h> before any STL headers #include <windows.h> #include <vector> #include <string> in which case, the macros get undefined or after all STL headers #include <vector> #include <string> #include <windows.h> in which case, the macros may haunt user code later. > > Considering the heavy use of min/max in standard C++ code (including gcc > headers), I think the best way to cure this problem is not to define > min/max by default for C++ in windef.h: > > --- windef.h.orig Sun Feb 09 22:47:03 2003 > +++ windef.h Mon Mar 03 15:38:25 2003 > @@ -135,7 +135,7 @@ > #endif > #endif > > -#ifndef NOMINMAX > +#if !defined(__cplusplus) || defined(USEMINMAX) > #ifndef max > #define max(a,b) ((a)>(b)?(a):(b)) > #endif > > Danny, how to do think about it? > I think that will cause problems with C++ code that doesn't use STL and expects the min,max macros to be defined by default. I recall that this came up on STLport list a year or so ago, I'll check the archives. Danny > > Best regards, > > Wu Yongwei > > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > MinGW-users mailing list > Min...@li... > > You may change your MinGW Account Options or unsubscribe at: > https://lists.sourceforge.net/lists/listinfo/mingw-users http://mobile.yahoo.com.au - Yahoo! Mobile - Exchange IMs with Messenger friends on your Telstra or Vodafone mobile phone. |