Skip to content

Commit

Permalink
[BUILD] Fix checks on __cplusplus under MSVC, do not assume /Zc (#2493)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcsgh authored Jan 18, 2024
1 parent 1467d66 commit 589dd2a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,15 @@
// C++ Version Check
// -----------------------------------------------------------------------------

// Enforce C++11 as the minimum. Note that Visual Studio has not
// advanced __cplusplus despite being good enough for our purposes, so
// so we exempt it from the check.
#if defined(__cplusplus) && !defined(_MSC_VER)
// Enforce C++11 as the minimum.
#if defined(_MSVC_LANG)
#if _MSVC_LANG < 201103L
#error "C++ versions less than C++11 are not supported."
#endif // _MSVC_LANG < 201103L
#elif defined(__cplusplus)
#if __cplusplus < 201103L
#error "C++ versions less than C++11 are not supported."
#endif
#endif // __cplusplus < 201103L
#endif

// -----------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ using underlying_type_t = typename std::underlying_type<T>::type;

namespace type_traits_internal {

#if __cplusplus >= 201703L
#if (!defined(_MSVC_LANG) && (__cplusplus >= 201703L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG >= 201703L))
// std::result_of is deprecated (C++17) or removed (C++20)
template<typename> struct result_of;
template<typename F, typename... Args>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ void print_value(const nostd::span<T> &vec, std::ostream &sout)
}

// Prior to C++14, generic lambda is not available so fallback to functor.
#if __cplusplus < 201402L
#if (!defined(_MSVC_LANG) && (__cplusplus < 201402L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG < 201402L))

class OwnedAttributeValueVisitor
{
Expand Down Expand Up @@ -97,7 +98,8 @@ class AttributeValueVisitor
inline void print_value(const opentelemetry::sdk::common::OwnedAttributeValue &value,
std::ostream &sout)
{
#if __cplusplus < 201402L
#if (!defined(_MSVC_LANG) && (__cplusplus < 201402L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG < 201402L))
opentelemetry::nostd::visit(OwnedAttributeValueVisitor(sout), value);
#else
opentelemetry::nostd::visit(
Expand All @@ -111,7 +113,8 @@ inline void print_value(const opentelemetry::sdk::common::OwnedAttributeValue &v

inline void print_value(const opentelemetry::common::AttributeValue &value, std::ostream &sout)
{
#if __cplusplus < 201402L
#if (!defined(_MSVC_LANG) && (__cplusplus < 201402L)) || \
(defined(_MSVC_LANG) && (_MSVC_LANG < 201402L))
opentelemetry::nostd::visit(AttributeValueVisitor(sout), value);
#else
opentelemetry::nostd::visit(
Expand Down

1 comment on commit 589dd2a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'OpenTelemetry-cpp sdk Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 589dd2a Previous: 1467d66 Ratio
BM_BaselineBuffer/1 5021731.853485107 ns/iter 1091216.5641784668 ns/iter 4.60
BM_LockFreeBuffer/1 1457165.9564971924 ns/iter 678246.021270752 ns/iter 2.15
BM_AlwaysOnSamplerConstruction 1.329565512137167 ns/iter 0.6184596706587192 ns/iter 2.15

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.