diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b17b207ae..9c010e6eea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -445,6 +445,11 @@ if(OTELCPP_MAINTAINER_MODE) add_compile_options(/wd4267) # Enforced warnings + add_compile_options(/we4265) # 'class': class has virtual functions, but + # destructor is not virtual + add_compile_options(/we5204) # A class with virtual functions has + # non-virtual trivial destructor. + elseif() message(FATAL_ERROR "Building with unknown compiler in maintainer mode.") endif() diff --git a/api/test/nostd/span_test.cc b/api/test/nostd/span_test.cc index 09d32ecfb8..98e825142d 100644 --- a/api/test/nostd/span_test.cc +++ b/api/test/nostd/span_test.cc @@ -182,10 +182,10 @@ TEST(SpanTest, Iteration) std::array array = {1, 2, 3}; span s1{array.data(), array.size()}; - EXPECT_EQ(std::distance(s1.begin(), s1.end()), array.size()); + EXPECT_EQ(std::distance(s1.begin(), s1.end()), (ptrdiff_t)array.size()); EXPECT_TRUE(std::equal(s1.begin(), s1.end(), array.begin())); span s2{array.data(), array.size()}; - EXPECT_EQ(std::distance(s2.begin(), s2.end()), array.size()); + EXPECT_EQ(std::distance(s2.begin(), s2.end()), (ptrdiff_t)array.size()); EXPECT_TRUE(std::equal(s2.begin(), s2.end(), array.begin())); } diff --git a/examples/http/client.cc b/examples/http/client.cc index d12a672049..ffba48940d 100644 --- a/examples/http/client.cc +++ b/examples/http/client.cc @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) // The port the validation service listens to can be specified via the command line. if (argc > 1) { - port = atoi(argv[1]); + port = (uint16_t)(atoi(argv[1])); } else { diff --git a/examples/http/server.cc b/examples/http/server.cc index 6b5947192b..13f250684e 100644 --- a/examples/http/server.cc +++ b/examples/http/server.cc @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) // The port the validation service listens to can be specified via the command line. if (argc > 1) { - server_port = atoi(argv[1]); + server_port = (uint16_t)atoi(argv[1]); } HttpServer http_server(server_name, server_port); diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tail_sampler.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tail_sampler.h index c4d0a2edd7..c7fa7ec0cf 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tail_sampler.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tail_sampler.h @@ -21,6 +21,7 @@ class TailSampler // Span::GetContext() virtual opentelemetry::sdk::trace::SamplingResult ShouldSample( const opentelemetry::trace::Span &span) noexcept = 0; + virtual ~TailSampler() = default; }; class AlwaysOnTailSampler : public TailSampler diff --git a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h index d1c6e16d96..eb3fd186df 100644 --- a/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h +++ b/ext/include/opentelemetry/ext/http/client/curl/http_operation_curl.h @@ -6,7 +6,13 @@ #include "opentelemetry/ext/http/client/http_client.h" #include "opentelemetry/version.h" -#include +#if defined(_MSC_VER) +# pragma warning(suppress : 5204) +# include +#else +# include +#endif + #include #include #include diff --git a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc index 4220509b74..1d2f96db00 100644 --- a/sdk/src/metrics/export/periodic_exporting_metric_reader.cc +++ b/sdk/src/metrics/export/periodic_exporting_metric_reader.cc @@ -6,7 +6,12 @@ #include "opentelemetry/sdk/metrics/push_metric_exporter.h" #include -#include +#if defined(_MSC_VER) +# pragma warning(suppress : 5204) +# include +#else +# include +#endif OPENTELEMETRY_BEGIN_NAMESPACE namespace sdk diff --git a/sdk/test/trace/tracer_test.cc b/sdk/test/trace/tracer_test.cc index 3287b39e5d..399c3c6d9f 100644 --- a/sdk/test/trace/tracer_test.cc +++ b/sdk/test/trace/tracer_test.cc @@ -271,11 +271,11 @@ TEST(Tracer, StartSpanWithAttributes) ASSERT_EQ(9, cur_span_data->GetAttributes().size()); ASSERT_EQ(314159, nostd::get(cur_span_data->GetAttributes().at("attr1"))); ASSERT_EQ(false, nostd::get(cur_span_data->GetAttributes().at("attr2"))); - ASSERT_EQ(314159, nostd::get(cur_span_data->GetAttributes().at("attr3"))); + ASSERT_EQ((uint32_t)314159, nostd::get(cur_span_data->GetAttributes().at("attr3"))); ASSERT_EQ(-20, nostd::get(cur_span_data->GetAttributes().at("attr4"))); - ASSERT_EQ(20, nostd::get(cur_span_data->GetAttributes().at("attr5"))); + ASSERT_EQ((uint32_t)20, nostd::get(cur_span_data->GetAttributes().at("attr5"))); ASSERT_EQ(-20, nostd::get(cur_span_data->GetAttributes().at("attr6"))); - ASSERT_EQ(20, nostd::get(cur_span_data->GetAttributes().at("attr7"))); + ASSERT_EQ((uint64_t)20, nostd::get(cur_span_data->GetAttributes().at("attr7"))); ASSERT_EQ(3.1, nostd::get(cur_span_data->GetAttributes().at("attr8"))); ASSERT_EQ("string", nostd::get(cur_span_data->GetAttributes().at("attr9")));