|
From: Wu Y. <ad...@ne...> - 2003-03-03 07:47:41
|
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.
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?
Best regards,
Wu Yongwei
|