Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] Fix checks on __cplusplus under MSVC, do not assume /Zc #2493

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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