diff --git a/api/include/opentelemetry/common/spin_lock_mutex.h b/api/include/opentelemetry/common/spin_lock_mutex.h index 97eae72cf9..48c7ecbeff 100644 --- a/api/include/opentelemetry/common/spin_lock_mutex.h +++ b/api/include/opentelemetry/common/spin_lock_mutex.h @@ -6,6 +6,17 @@ #include "opentelemetry/version.h" +#if defined(_MSC_VER) +# ifndef NOMINMAX +# define NOMINMAX +# endif +# include +#elif defined(__i386__) || defined(__x86_64__) +# if defined(__clang__) +# include +# endif +#endif + OPENTELEMETRY_BEGIN_NAMESPACE namespace common { diff --git a/api/include/opentelemetry/nostd/string_view.h b/api/include/opentelemetry/nostd/string_view.h index 4a5bdefa81..3f68b029b3 100644 --- a/api/include/opentelemetry/nostd/string_view.h +++ b/api/include/opentelemetry/nostd/string_view.h @@ -87,7 +87,7 @@ class string_view int compare(string_view v) const noexcept { - size_type len = std::min(size(), v.size()); + size_type len = (std::min)(size(), v.size()); int result = Traits::compare(data(), v.data(), len); if (result == 0) result = size() == v.size() ? 0 : (size() < v.size() ? -1 : 1); diff --git a/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h b/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h index 38f34113af..d23a805e8e 100644 --- a/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h +++ b/api/include/opentelemetry/plugin/detail/dynamic_load_windows.h @@ -7,10 +7,13 @@ #include "opentelemetry/plugin/hook.h" #include "opentelemetry/version.h" -#include +#ifndef NOMINMAX +# define NOMINMAX +#endif +#include +#include #include -#include OPENTELEMETRY_BEGIN_NAMESPACE namespace plugin diff --git a/api/include/opentelemetry/std/span.h b/api/include/opentelemetry/std/span.h index da9fcb48a3..fc7c35ab9a 100644 --- a/api/include/opentelemetry/std/span.h +++ b/api/include/opentelemetry/std/span.h @@ -67,7 +67,7 @@ OPENTELEMETRY_END_NAMESPACE OPENTELEMETRY_BEGIN_NAMESPACE namespace nostd { -constexpr std::size_t dynamic_extent = std::numeric_limits::max(); +constexpr std::size_t dynamic_extent = (std::numeric_limits::max()); template using span = std::span; diff --git a/ext/include/opentelemetry/ext/http/server/socket_tools.h b/ext/include/opentelemetry/ext/http/server/socket_tools.h index 095a7eeeff..faa4da75a4 100644 --- a/ext/include/opentelemetry/ext/http/server/socket_tools.h +++ b/ext/include/opentelemetry/ext/http/server/socket_tools.h @@ -207,7 +207,7 @@ struct SocketAddr { inet4.sin_port = htons(atoi(colon + 1)); char buf[16]; - memcpy(buf, addr, std::min(15, colon - addr)); + memcpy(buf, addr, (std::min)(15, colon - addr)); buf[15] = '\0'; ::inet_pton(AF_INET, buf, &inet4.sin_addr); } diff --git a/sdk/include/opentelemetry/sdk/metrics/aggregator/sketch_aggregator.h b/sdk/include/opentelemetry/sdk/metrics/aggregator/sketch_aggregator.h index 9f0545d993..26baba5b42 100644 --- a/sdk/include/opentelemetry/sdk/metrics/aggregator/sketch_aggregator.h +++ b/sdk/include/opentelemetry/sdk/metrics/aggregator/sketch_aggregator.h @@ -68,7 +68,7 @@ class SketchAggregator final : public Aggregator int idx; if (val == 0) { - idx = std::numeric_limits::min(); + idx = (std::numeric_limits::min()); } else { diff --git a/sdk/src/common/fast_random_number_generator.h b/sdk/src/common/fast_random_number_generator.h index 9c7367fa77..72bc46c1b9 100644 --- a/sdk/src/common/fast_random_number_generator.h +++ b/sdk/src/common/fast_random_number_generator.h @@ -17,6 +17,17 @@ namespace common * std::mt19937_64; and since we don't care about the other beneficial random * number properties that std:mt19937_64 provides for this application, it's a * entirely appropriate replacement. + * + * Note for Windows users - please make sure that NOMINMAX is defined, e.g. + * + * ... + * #define NOMINMAX + * #include + * ... + * + * See: + * https://stackoverflow.com/questions/13416418/define-nominmax-using-stdmin-max + * */ class FastRandomNumberGenerator {