What problems could I get when defining NOMINMAX before anything else in my program?
As far as I know, this will make not
I generally use NOMINMAX like this to limit the potential side effects:
#define NOMINMAX
#include
#undef NOMINMAX
That way the scope of the NOMINMAX is relatively confined.
It's not a perfect solution. If something else has already defined NOMINMAX, this pattern fails (though I've never encountered such a case).
If you want to be really, really careful, then you can #include a wrapper header wherever you would have #included windows.h. The wrapper would go something like this:
/* Include this file instead of including directly. */
#ifdef NOMINMAX
#include
#else
#define NOMINMAX
#include
#undef NOMINMAX
#endif
You could imagine doing other things in the wrapper, too, like enforcing UNICODE and/or STRICT.