When defining NOMINMAX before including windows.h, min and max aren't defined. __min and __max are always defined though. So use them instead.
This patch simply consist of a search of replace for both term.
Thanks for the patch. This is now fixed.