ANSI C++

Will Schroeder will.schroeder at kitware.com
Wed Apr 19 07:02:39 EDT 2000


Hi Folks-

I've been working on some changes (with Bill Hoffman's assistance) to make
vtk ANSI C++ compliant (meaning we can start mixing in STL). While the
changes are simple, they are pervasive since the majority of files in the
system are touched. I'd like feedback on what's been done as described in
the following. I'd also like to schedule a date next week for
check-in....it's likely to be messy so we ought to plan for a couple of
days of instability.

1. Creation of several typedefs and #defines, and inclusion of the correct
headers as follows. These are placed into a new header file called
vtkSystemIncludes.h. ANSI C++ is enabled by defining VTK_USE_ANSI_STDLIB.
(Note: I pulled some of the #includes out of the vtkWin32Header.h file.)

#if defined(_WIN32) || defined(WIN32)
// Handle changes from ANSI C++
#ifdef VTK_USE_ANSI_STDLIB
#include <iostream>
#include <ostrstream>
#include <fstream>
typedef std::ostream vtkOstream;
typedef std::istream vtkIstream;
#define vtkEndl std::endl
typedef std::ostrstream vtkOstrstream;
typedef std::istrstream vtkIstrstream;
#define vtkEnds std::ends
typedef std::ifstream vtkIfstream;
typedef std::ofstream vtkOfstream;
#else
#include <iostream.h>
#include <strstrea.h>
#include <fstream.h>
typedef ostream vtkOstream;
typedef istream vtkIstream;
#define vtkEndl endl
typedef ostrstream vtkOstrstream;
typedef istrstream vtkIstrstream;
#define vtkEnds ends
typedef ifstream vtkIfstream;
typedef ofstream vtkOfstream;
#endif
//
// UNIX specific stuff---------------------------------------------
#else
// Handle changes from ANSI C++
#ifdef VTK_USE_ANSI_STDLIB
#include <iostream>
#include <strstream>
#include <fstream>
typedef std::ostream vtkOstream;
typedef std::istream vtkIstream;
#define vtkEndl std::endl
typedef std::ostrstream vtkOstrstream;
typedef std::istrstream vtkIstrstream;
#define vtkEnds std::ends
typedef std::ifstream vtkIfstream;
typedef std::ofstream vtkOfstream;
#else
#include <iostream.h>
#include <strstream.h>
#include <fstream.h>
typedef ostream vtkOstream;
typedef istream vtkIstream;
#define vtkEndl endl
typedef ostrstream vtkOstrstream;
typedef istrstream vtkIstrstream;
#define vtkEnds ends
typedef ifstream vtkIfstream;
typedef ofstream vtkOfstream;
#endif
#endif

(There are small differences between Windows and Unix as you can see.)

2. Used a Perl script to change all the "ostream -> vtkOstream", "endl
->vtkEndl", etc. in .h & .cxx files (including examples).

3. Removed all places where one of iostream, strstream, and fstream were
included, making sure that vtkSystemIncludes.h was used in its place.
I haven't tested all the combinations as of yet...I'm going to do so over
the next couple of days (so there might be some bad goofs in the include
file). If you see anything, or have any comments, I'd appreciate it.

Will

PS - for those working on NLM Insight project, these changes are necessary
if we are to link the system together.




More information about the vtk-developers mailing list