Massive check-in for C++ ANSI-compatible VTK

Will Schroeder will.schroeder at kitware.com
Tue Apr 25 10:40:45 EDT 2000


Hi Folks-

This message describes changes made to VTK to support ANSI C++. The changes will be checked in today, and the VTK nightly build will most likely be unstable for a day or two. The majority of files in VTK have been modified in some way.

Purpose: 
Allow user's to employ ANSI C++ features including STL and the std:: classes (e.g., std::string, std::cout, etc.).

Changes: 
* Creation of a vtkSystemIncludes.h file to encapsulate the changes made to iostream, fstream, and strstream required to support ANSI C++. 
* Definition of the #defines vtkCerr, vtkCin, vtkCout, vtkIos, vtkEndl, vtkEnds 
* Definition of the typedefs vtkOstream, vtkIstream, vtkOstrstream, vtkIstrstream, vtkIfstream, vtkOfstream. 
* Replacements of things like "ostream" with "vtkOstream" (see the PrinstSelf() methods, for example). In this example, the typedef vtkOstream is defined as "std::ostream" for ANSI C++, and "ostream" for non-ANSI. 
* Definition of the compile time flag VTK_USE_ANSI_STDLIB which enables ANSI C++ compilation.

Usage: 
* If you'd like to compile non-ANSI C++ (like VTK is now), don't do anything. 
* If you'd like to compile with ANSI C++, compile with VTK_USE_ANSI_STDLIB and set the compiler flags appropriate to your compiler. (For example, in MS Visual C++, I'm setting the advanced flags in pcmaker to: /D "VTK_USE_ANSI_STDLIB" /GX /Zm1000 (the /GX turns on exception handling, Zm1000 requests 10x more compiler memory...I didn't say ANSI C++ was pretty).
Implications: 

In theory, many VTK classes could be re-written using STL. However, we do not plan on doing this for a long time, since this would require that all users build with ANSI C++ compilers. Since there are a lot of non-ANSI compilers out there, this is a bad idea in the short term. What this does mean is that user's can create their own classes using ANSI features and link to ANSI-libraries/systems. Unfortunately, we cannot distribute as part of mainstream VTK any of these classes that make use of ANSI features (at least for a while).

Other Notes: 
* I have a perl script that can convert older classes to support ANSI C++ using the methods described above. If there is enough interest I'll send it/post it.
* Strictly speaking, a persnickety ANSI compiler will not digest the modified code. Casts like (vtkRenderer *) should really use static_cast (or dynamic_cast). And I'm sure there may be others as well. 

Will 

--------------------------------------------------------------------
This is the private VTK discussion list. Please keep messages on-topic.
Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
To UNSUBSCRIBE, send message body containing "unsubscribe vtkusers" to
<majordomo at public.kitware.com>. For help, send message body containing
"info vtkusers" to the same address.
--------------------------------------------------------------------



More information about the vtkusers mailing list