Its best practice (and necessary) to define the NOMINMAX macro before including “Windows.h”.
I’m using JUCE, the CURL library, and including “Windows.h” directly. Whilst JUCE defines NOMINMAX before including “Windows.h” in the other cases (including “Curl.h” or “Windows.h”) I need to ensure NOMINMAX is always defined first in the compilation unit.
The best solution would be to define NOMINMAX in my build system so it is always set by the compiler. However doing this will cause a warning because it is being redefined in the JUCE code (or an error with /WX set).
To avoid this problem other libraries I use either don’t define it at all (like curl) or check first if NOMINMAX is already defined. If JUCE could do something like this NOMINMAX can be defined by the compiler / build system without breaking any current build set ups -
The JUCE definition I’m talking about is here -
Some examples of other libraries using this same strategy -
I’m surprised this hasn’t come up before. Please let me know if there is some better build setup I’m missing!