c++visual-studio-2010

Exclude a system header file in VS2010


I'm wondering how to exclude a specified system header file in VS2010, which makes an ambiguous problem.

In my project, I use an opensource project. In which a cpp file calls

std::something::max()

where the max is a method in something.

However, max is also defined in a system header file "minwindef.h", which in my case lies at \Windows Kits\8.0\shared\minwidef.h

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

I think this is not necessary for my project.

So how do I manually prohibit this file to be included (perhaps recursively)?


Solution

  • You might want to #define NOMINMAX before #includeing any Windows headers.

    This is such a common problem that they added this macro to remove the min and max definitions that conflict with the stl versions.

    I'll try and dig up some MSDN reference for this.