namespace and STL (and 2.97)
Carlo Wood
carlo@alinoe.com
Tue Nov 14 12:03:00 GMT 2000
Hi, today I got the latest CVS copy of gcc (2.97 20001114) and found that
the STL functions suddenly are not in namespace std:: anymore!?
The "reason" turns out to be that in the file stl_config.h we now find:
# ifdef __GNUC__
# include <_G_config.h>
# define __STL_HAS_WCHAR_T
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
# define __STL_STATIC_TEMPLATE_MEMBER_BUG
# define __STL_NEED_TYPENAME
# define __STL_NEED_EXPLICIT
# else
# define __STL_CLASS_PARTIAL_SPECIALIZATION
# define __STL_FUNCTION_TMPL_PARTIAL_ORDER
# define __STL_MEMBER_TEMPLATES
# define __STL_MEMBER_TEMPLATE_CLASSES
# define __STL_EXPLICIT_FUNCTION_TMPL_ARGS
# define __STL_HAS_NAMESPACES
# define __STL_NO_NAMESPACES
With __GNUC__ == 2 and __GNUC_MINOR__ == 97 we reach the last line
shown here which defines __STL_NO_NAMESPACES
I must say, this highly confuses me. I did not have this problem with
2.95.x or 2.96, while (at least) the latter has the same stl_config.h.
../../../libcw/src/libcwd/debug.cc: In member function `void libcw::debug::debug_ct::init()':
../../../libcw/src/libcwd/debug.cc:442: `find' undeclared in namespace `std'
According the C++ draft that I have, `find' must be in namespace std:
25 Algorithms library [lib.algorithms]
...
Header <algorithm> synopsis
namespace std {
...
template<class InputIterator, class T>
InputIterator find(InputIterator first, InputIterator last, const T& value);
In order to reproduce this please compile the following example:
--------------
#include <algorithm>
#include <list>
int main(void)
{
list<int> l;
::std::find(l.begin(), l.end(), 0);
return 0;
}
--------------
~>g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.0)
~>g++ troep.cc
~>
~>g++-cvs -v
Reading specs from /usr/local/gcc/lib/gcc-lib/i686-pc-linux-gnu/2.97/specs
Configured with: ../gcc-cvs/configure --prefix=/usr/local/gcc --enable-shared --with-gnu-as --with-gnu-ld --enable-languages=c++
gcc version 2.97 20001114 (experimental)
~>g++-cvs troep.cc
troep.cc: In function `int main()':
troep.cc:8: `find' undeclared in namespace `std'
Regards,
--
Carlo Wood <carlo@alinoe.com> -=- Jesus Loves you -=-
More information about the Gcc-bugs
mailing list