Reputation: 3407
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)?
Upvotes: 1
Views: 1941
Reputation: 129524
Most likely, your opensource project is not designed to be "mixed" with "windows" headers.
Just don't do #include <windows.h>
into the same files that include your opensource project. The limit the includes of <windows.h>
to only be included in files that ABSOLUTELY need to have it, and idealy have one or more files with "windows only" functionality that are then provided to the rest of the code via it's own headers, isolating any windows functionality - that will also help if you ever decide to port your system to something other than windows.
(There are whole bunch of other macros that will sooner or late come back and bite you if you keep including Windows in your overall project)
Upvotes: 1
Reputation: 2456
You might want to #define NOMINMAX
before #include
ing 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.
Upvotes: 3