- Defined NOMINMAX macro to disable windef.h's min/max macros; they were clashing with the C++ standard library's std::min/std::max.
- All uses of min/max that had ambiguous type deduction were explicitly instantiated as min<long> and max<long>.
- Header includes were sorted
Many thanks to DKO for the patch.
<wtypes.h> may include all the BOOL/DWORD/etc. stuff as a low-level MSVC header, but it is not obligated to do so per the low-level header specifications for other compilers, such as (evidently) MinGW.
The old code only cared about if the macro was already defined (then #undef and re-define it). If it was NOT already defined, it just ignored the problem and causes unresolved compile-time symbols.