[vtkusers] ANSI C++ stdlib issue (windows)

Sebastien BARRE seb-ml-vtk at barre.nom.fr
Mon Oct 9 13:43:44 EDT 2000


At 16/09/00 09:06, Will Schroeder wrote:

>Hi Kent-
>
>VTK already has the capability. You have to compile with the compile-flag
>VTK_USE_ANSI_STDLIB. You'll also want to set appropriate compiler flags.
>
>(For example, in MS Visual C++, set 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).

You might be interested in adding the following flag too :
  /D "NOMINMAX"

The reason is : I tried to use VTK with MTL/ITL, a numerical lib using 
heavily C++ templated classes, generic programming and STL-like (Standard 
Template Library) stuff.

It failed because MTL/ITL implements max/min functions for matrix/vector 
types (and I guess the STL does too for the usual numeric types), BUT these 
functions *clash* with the max/min macros :(
Where do these macros come from ? : believe it or not, they come from the 
"windef.h" file, which is included by VTK (through windows.h I guess).

Here is an excerpt of windef.h :

#ifndef NOMINMAX
#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif
#endif  /* NOMINMAX */

Thus, if you encounter clash problems with min/max macros, do not forget to 
use :
  /D "NOMINMAX"

Hope this helps





More information about the vtkusers mailing list