[vtkusers] namespace problems..

Mumit Khan khan at NanoTech.Wisc.EDU
Sat Feb 17 17:25:00 EST 2001


On Sat, 17 Feb 2001, K.R.Subramanian wrote:

> 
> I am using the standard template library (list, vector, iostream) in
> vtk applications, but
> the "using" directive doesnt seem to do the right thing.
> 
> 
> for instance:
> 
> *****************************
> #include <list>
> #include <vector>
> #include <iostream>
> #include <vtkStructuredPoints.h>
> 
> using namespace std;
>
[ ... ]
> 
> 
>     cout << b[0] << "," << b[1] << "," << b[2] << endl;
> 
[ ... ]

> cc-1239 CC: ERROR File = tmp1.cc, Line = 18
>   "cout" is ambiguous.
> 
>         cout << b[0] << "," << b[1] << "," << b[2] << endl;
>         ^
> ***********************************
> 1 error detected in the compilation of "tmp1.cc".
> 
> 
> Without the vtk include file, there is no problem.

It's a problem with your compiler. vtkSystemIncludes.h, one of the VTK
files that is indirectly included by vtkStructuredPoints.h, adds the
following bits:

  using std::cout;
  using std::endl;
  ...

and then you import all of std namespace, and it's confusing the
compiler. SGI may have patches/updates that you may want to check
for. 

I'd of course like to see all using statements removed from headers
that are included by client code, but that's going to take some boring
work. The easiest way is to incldue the using bits at the top of, and
after all the runtime includes, each source file.

Regards,
Mumit






More information about the vtkusers mailing list