Summary:
This makes it easier to consume Folly from a non-cmake project.
Note that this also requires making libevent, which was previously categorized as a semi-portable header into a non-portable header, meaning it can't be referenced directly. (libevent includes `Windows.h` in one of its headers -_-....)
Reviewed By: yfeldblum
Differential Revision:
D5106051
fbshipit-source-id:
5ce2d4188c9036d6ab206af3036c8fd4b09516a4
# And the extra defines:\r
target_compile_definitions(${THETARGET}\r
PUBLIC\r
- NOMINMAX # 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.\r
_CRT_NONSTDC_NO_WARNINGS # Don't deprecate posix names of functions.\r
_CRT_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps.\r
_SCL_SECURE_NO_WARNINGS # Don't deprecate the non _s versions of various standard library functions, because safety is for chumps.\r
#pragma once
#include <folly/io/async/EventBase.h>
-#include <event.h>
+#include <folly/portability/Event.h>
#include <map>
namespace folly {
#include <folly/portability/Event.h>
#include <boost/noncopyable.hpp>
-#include <event.h>
#include <memory>
#include <utility>
#include <folly/io/async/HHWheelTimer.h>
#include <folly/io/async/Request.h>
#include <folly/io/async/TimeoutManager.h>
+#include <folly/portability/Event.h>
#include <glog/logging.h>
-#include <event.h> // libevent
namespace folly {
#pragma once
#include <functional>
-#include <event.h> // libevent
+
+#include <folly/portability/Event.h>
namespace folly {
#pragma once
+#ifdef _MSC_VER
+// This needs to be before the libevent include.
+# include <folly/portability/Windows.h>
+#endif
+
#include <event.h>
#ifdef _MSC_VER
# include <event2/event_compat.h>
# include <folly/portability/Fcntl.h>
-# include <folly/portability/Windows.h>
#endif
namespace folly {
#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>