Shift the job of defining NOMINMAX into source rather than the build system
[folly.git] / folly / portability / Windows.h
index 2cb0bda86769d89cfbf9c35457635ba66394348c..7ccfde8c01a99eafd109ff4ef9d574d6851291bf 100755 (executable)
 #include <direct.h> // nolint
 #endif
 
 #include <direct.h> // nolint
 #endif
 
+#if defined(min) || defined(max)
+#error Windows.h needs to be included by this header, or else NOMINMAX needs \
+ to be defined before including it yourself.
+#endif
+
+// This is needed because, for some absurd reason, one of the windows headers
+// tries to define "min" and "max" as macros, which messes up most uses of
+// std::numeric_limits.
+#ifndef NOMINMAX
+#define NOMINMAX 1
+#endif
+
 #include <WinSock2.h>
 #include <Windows.h>
 
 #include <WinSock2.h>
 #include <Windows.h>