[Insight-users] ITK undefining min and max macros causes GdiplusTypes.h to not compile

Luis Ibanez luis.ibanez at kitware.com
Tue Jul 18 18:44:42 EDT 2006



Hi Mike,


Just for the record, it was a monumental abuse on the part of Microsoft
to take the liberty of defining the "min" and "max" symbols as macros.

It is one of the actions that derives from the state of mind of
believing that they are the only software company in the world.

Note that ITK/CMake is just fixing what Microsoft broke. You don't want
to remove this definition from the ITKConfig.cmake because then when
you find methods in ITK and VXL that use min and max symbols (even
though they are nicely defined inside namespaces) they will conflict
with the abusive Microsoft macros.


This is not an ITK problem. It is a Microsoft problem.
Even expressions from the standard C++ STL such as

              numeric_limits<int>::max()

will not work unless you define NOMINMAX.



The way you can restore those obnoxious macro definitions is to do

#ifdef NOMINMAX
#undef NOMINMAX
#include GdiplusType.h

     // here your code that relies on
     // abusive Microsoft macros to exist...


#endif






   Regards,



       Luis



------------------------
Mike Tabaczynski wrote:
> Hi
> 
> In the ITK installed file \ITK\ITKConfig.cmake, the line
> "SET(ITK_REQUIRED_CXX_FLAGS " -DNOMINMAX")" undefines the min and max macros
> causing the Microsoft GdiplusTypes.h file to not compile. This doesn't
> happen when building the examples. I don't include that file anywhere in my
> code. Just a guess, but maybe my project includes .h files in some
> combination that wasn't tried during ITK testing?
> 
> The best workaround I can find is to just modify ITKConfig.cmake and delete
> that line. I couldn't find anything in the cmake or ITK doc about how to fix
> or override this build behavior. Is there something I can do in my project
> CMakeLists.txt? Looking through the ITK files I don't really see why ITK
> undefines the min and max macros in the first place.
> 
> Thanks
> MikeT
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 




More information about the Insight-users mailing list