diff --git a/src/xrpld/telemetry/MetricMacros.h b/src/xrpld/telemetry/MetricMacros.h index 827213c393..940f916de5 100644 --- a/src/xrpld/telemetry/MetricMacros.h +++ b/src/xrpld/telemetry/MetricMacros.h @@ -101,6 +101,18 @@ * tasks/metric-macro-plan.md. */ +// On Windows, OTel's spin_lock_mutex.h (transitively included from +// MetricsRegistry.h) defines _WINSOCKAPI_ and includes , which +// pulls in WinSock 1. ServiceRegistry.h below then includes , +// whose socket_types.hpp requires winsock2.h first and errors out if WinSock 1 +// arrived earlier. Pre-including boost's socket types header here gets +// winsock2.h in before the OTel headers, so any translation unit that includes +// MetricMacros.h first (e.g. the telemetry unit tests) still compiles. The +// production MetricsRegistry.cpp carries the same guard. +#ifdef _MSC_VER +#include +#endif + #include // IWYU pragma: keep #include // IWYU pragma: keep