diff --git a/CMakeLists.txt b/CMakeLists.txt index c9fd35d8aa..c29a5e9912 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -67,7 +67,7 @@ if(WITH_STL) add_definitions(-DHAVE_CPP_STDLIB) add_definitions(-DHAVE_GSL) # Require at least C++17. C++20 is needed to avoid gsl::span - if(CMAKE_MINOR_VERSION VERSION_GREATER "3.18") + if(CMAKE_VERSION VERSION_GREATER 3.18.0) # Ask for 20, may get anything below set(CMAKE_CXX_STANDARD 20) else() @@ -92,8 +92,7 @@ if(WITH_STL) set(MSVC_CXX_OPT_FLAG "/O2") endif() endif() - set(CMAKE_CXX_FLAGS - "${CMAKE_CXX_FLAGS} /Zc:__cplusplus ${MSVC_CXX_OPT_FLAG}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CXX_OPT_FLAG}") endif() endif() @@ -168,8 +167,10 @@ if(MSVC) # Options for Visual C++ compiler: /Zc:__cplusplus - report an updated value # for recent C++ language standards. Without this option MSVC returns the # value of __cplusplus="199711L" - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") - + if(MSVC_VERSION GREATER 1900) + # __cplusplus flag is not supported by Visual Studio 2015 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") + endif() # When using vcpkg, all targets build with the same runtime if(VCPKG_TOOLCHAIN) set(CMAKE_MSVC_RUNTIME_LIBRARY diff --git a/api/include/opentelemetry/trace/propagation/b3_propagator.h b/api/include/opentelemetry/trace/propagation/b3_propagator.h index 77d736bedc..9aac90f03e 100644 --- a/api/include/opentelemetry/trace/propagation/b3_propagator.h +++ b/api/include/opentelemetry/trace/propagation/b3_propagator.h @@ -139,11 +139,11 @@ class B3Propagator : public B3PropagatorExtractor char trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 3]; static_assert(sizeof(trace_identity) == 51, "b3 trace identity buffer size mismatch"); - span_context.trace_id().ToLowerBase16( - nostd::span{&trace_identity[0], kTraceIdHexStrLength}); + span_context.trace_id().ToLowerBase16(nostd::span{ + &trace_identity[0], static_cast(kTraceIdHexStrLength)}); trace_identity[kTraceIdHexStrLength] = '-'; span_context.span_id().ToLowerBase16(nostd::span{ - &trace_identity[kTraceIdHexStrLength + 1], kSpanIdHexStrLength}); + &trace_identity[kTraceIdHexStrLength + 1], static_cast(kSpanIdHexStrLength)}); trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 1] = '-'; trace_identity[kTraceIdHexStrLength + kSpanIdHexStrLength + 2] = span_context.trace_flags().IsSampled() ? '1' : '0'; diff --git a/api/test/nostd/variant_test.cc b/api/test/nostd/variant_test.cc index 428d31e624..cea5c4ee7b 100644 --- a/api/test/nostd/variant_test.cc +++ b/api/test/nostd/variant_test.cc @@ -27,6 +27,7 @@ TEST(VariantSizeTest, GetVariantSize) EXPECT_EQ((nostd::variant_size>::value), 2); } +#if 0 // Disable this test for now. It does not compile with Visual Studio 2015. TEST(VariantAlternativeTest, GetVariantSize) { EXPECT_TRUE((std::is_same>, int>::value)); @@ -35,6 +36,7 @@ TEST(VariantAlternativeTest, GetVariantSize) EXPECT_TRUE((std::is_same>, const double>::value)); } +#endif TEST(VariantTest, Get) { diff --git a/examples/grpc/client.cpp b/examples/grpc/client.cpp index 5ebdbf617d..719a62225b 100644 --- a/examples/grpc/client.cpp +++ b/examples/grpc/client.cpp @@ -1,12 +1,14 @@ +// Make sure to include GRPC headers first because otherwise Abseil may create +// ambiguity with `nostd::variant` if compiled with Visual Studio 2015. Other +// modern compilers are unaffected. +#include +#include "messages.grpc.pb.h" + #include "tracer_common.h" #include #include #include -#include - -#include "messages.grpc.pb.h" - using grpc::Channel; using grpc::ClientContext; using grpc::ClientReader; diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h index 9fe479b7eb..a6243c46db 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_traceloggingdynamic.h @@ -8,7 +8,8 @@ # endif # endif #else -# ifdef HAVE_TLD -# include "TraceLoggingDynamic.h" +# ifndef HAVE_TLD +# define HAVE_TLD # endif +# include "TraceLoggingDynamic.h" #endif diff --git a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h index 7cf6edea24..2806bfa593 100644 --- a/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h +++ b/exporters/etw/include/opentelemetry/exporters/etw/etw_tracer.h @@ -291,8 +291,12 @@ static inline bool CopySpanIdToActivityId(const trace::SpanContext &spanContext, { return false; } - auto spanId = spanContext.span_id().Id().data(); - std::copy(spanId, spanId + 8, reinterpret_cast(&outGuid)); + auto spanId = spanContext.span_id().Id().data(); + uint8_t *guidPtr = reinterpret_cast(&outGuid); + for (size_t i = 0; i < 8; i++) + { + guidPtr[i] = spanId[i]; + } return true; }; diff --git a/exporters/etw/test/etw_perf_test.cc b/exporters/etw/test/etw_perf_test.cc index f2d28c094b..d25ea73957 100644 --- a/exporters/etw/test/etw_perf_test.cc +++ b/exporters/etw/test/etw_perf_test.cc @@ -14,9 +14,7 @@ using namespace OPENTELEMETRY_NAMESPACE; -using Properties = opentelemetry::exporter::etw::Properties; -using PropertyValue = opentelemetry::exporter::etw::PropertyValue; -using PropertyValueMap = opentelemetry::exporter::etw::PropertyValueMap; +using namespace opentelemetry::exporter::etw; namespace { diff --git a/exporters/etw/test/etw_tracer_test.cc b/exporters/etw/test/etw_tracer_test.cc index 5d741d5b75..45d49356c8 100644 --- a/exporters/etw/test/etw_tracer_test.cc +++ b/exporters/etw/test/etw_tracer_test.cc @@ -12,9 +12,7 @@ using namespace OPENTELEMETRY_NAMESPACE; -using Properties = opentelemetry::exporter::etw::Properties; -using PropertyValue = opentelemetry::exporter::etw::PropertyValue; -using PropertyValueMap = opentelemetry::exporter::etw::PropertyValueMap; +using namespace opentelemetry::exporter::etw; std::string getTemporaryValue() {