This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Help : Is this a namespace collision ??
- From: m. <michal017 at centrum dot sk>
- To: Christian POKAM <chrispot at cs dot tu-berlin dot de>
- Cc: gcc-help at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Mon, 25 Nov 2002 07:42:36 +0100
- Subject: Re: Help : Is this a namespace collision ??
- References: <1038203751.7809.17.camel@mami>
Just read what the compiler says..
>NewHandler.cpp:12: first declared as `int count' here
>/usr/include/c++/3.2.1/bits/stl_algo.h:390: also declared as `
> std::iterator_traits<_Iterator>::difference_type
>std::count(_InputIter,
> _InputIter, const _Tp&)' here
There's a function std::count() declared in bits/stl_algo.h..
m.
On 25 Nov 2002 06:55:52 +0100
Christian POKAM <chrispot@cs.tu-berlin.de> wrote:
> Why is the Compilation of NewHandler.cpp complaining about
> the ambigous use of "count" ??
> Thank you
>
>//NewHandler.cpp
>// From Thinking in C++, 2nd Edition
>// Available at http://www.BruceEckel.com
>// (c) Bruce Eckel 2000
>// Copyright notice in Copyright.txt
>// Changing the new-handler
>#include <iostream>
>#include <cstdlib>
>#include <new>
>using namespace std;
>
>int count = 0;
>
>void out_of_memory() {
> cerr << "memory exhausted after " << count
> << " allocations!" << endl;
> exit(1);
>}
>
>int main() {
> set_new_handler(out_of_memory);
> while(1) {
> count++;
> new int[1000]; // Exhausts memory
> }
>} //
>
>
>gcc version 3.2.1 ; linux kernel 2.4.19 ; glibc 2.3.1
>gcc output:
>
>NewHandler.cpp: In function `void out_of_memory()':
>NewHandler.cpp:16: use of `count' is ambiguous
>NewHandler.cpp:12: first declared as `int count' here
>/usr/include/c++/3.2.1/bits/stl_algo.h:390: also declared as `
> std::iterator_traits<_Iterator>::difference_type
>std::count(_InputIter,
> _InputIter, const _Tp&)' here
>NewHandler.cpp: In function `int main()':
>NewHandler.cpp:23: use of `count' is ambiguous
>NewHandler.cpp:12: first declared as `int count' here
>/usr/include/c++/3.2.1/bits/stl_algo.h:390: also declared as `
> std::iterator_traits<_Iterator>::difference_type
>std::count(_InputIter,
> _InputIter, const _Tp&)' here
>
>
>--
>Christian POKAM <chrispot@cs.tu-berlin.de>
>