Skip to content

Commit

Permalink
Fix issue open-telemetry#834
Browse files Browse the repository at this point in the history
Signed-off-by: owent <[email protected]>
  • Loading branch information
owent committed Jun 8, 2021
1 parent 01837f5 commit b806b57
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ option(WITH_STL "Whether to use Standard Library for C++latest features" OFF)
option(WITH_ABSEIL "Whether to use Abseil for C++latest features" OFF)

if(WITH_ABSEIL)
add_definitions(-DHAVE_ABSEIL)
find_package(absl CONFIG REQUIRED)

set(CORE_RUNTIME_LIBS absl::any absl::base absl::bits absl::city)
Expand Down
4 changes: 4 additions & 0 deletions api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ if(BUILD_TESTING)
add_subdirectory(test)
endif()

if(WITH_ABSEIL)
target_compile_definitions(opentelemetry_api INTERFACE HAVE_ABSEIL)
endif()

if(WITH_STL)
message("Building with standard library types...")
target_compile_definitions(opentelemetry_api INTERFACE HAVE_CPP_STDLIB
Expand Down
2 changes: 1 addition & 1 deletion api/include/opentelemetry/nostd/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OPENTELEMETRY_END_NAMESPACE
# endif

# ifdef HAVE_ABSEIL
# include "absl/types/variant.h"
# include <absl/types/variant.h>
# else
# include "./absl/types/variant.h"
# endif
Expand Down
12 changes: 11 additions & 1 deletion sdk/src/common/core.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "opentelemetry/nostd/variant.h"
// clang-format on

#if defined(HAVE_ABSEIL)
#if !defined(HAVE_CPP_STDLIB) && !defined(OTABSL_USES_STD_VARIANT)
/* The option of building and linking with Abseil library implies that Abseil
* may already provide the ThrowBadVariantAccess implementation if its own.
* Reconsider the implementation below: we are potentially introducing
Expand All @@ -28,9 +28,19 @@

namespace absl
{
# if defined(HAVE_ABSEIL)
ABSL_NAMESPACE_BEGIN
# else
OTABSL_NAMESPACE_BEGIN
# endif
namespace variant_internal
{
void __cdecl ThrowBadVariantAccess(){/* TODO: std::terminate or re-throw? */};
}
# if defined(HAVE_ABSEIL)
ABSL_NAMESPACE_END
# else
OTABSL_NAMESPACE_END
# endif
} // namespace absl
#endif

0 comments on commit b806b57

Please sign in to comment.