-
Notifications
You must be signed in to change notification settings - Fork 417
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
context::ContextValue cannot be compiled with Visual Studio 2015 #314
Comments
I explored the last option. Abseil Verified that this patch allows to replace the implementation in ...
#elif defined(HAVE_ABSEIL)
#include "absl/types/variant.h"
OPENTELEMETRY_BEGIN_NAMESPACE
namespace nostd
{
using absl::variant;
using absl::get;
} // namespace nostd
OPENTELEMETRY_END_NAMESPACE
namespace absl
{
namespace variant_internal
{
void __cdecl ThrowBadVariantAccess(){};
}
} // namespace absl
#else
... |
@pyohannes @g-easy @reyang @ThomsonTan @lalitb --- I'd like to discuss this during our next meeting, that possibly on Windows (and maybe other OS) we should use Abseil's port of This code allows to compile with I'm thinking of approach where we use Abseil's header, but for the throw routine we provide our own stub. That way we do not have to link against Abseil. At this time I do need Visual Studio 2015 support. One of my prominent customers is still on that compiler. |
Replace the implementation of nostd::variant with Abseil's variant.h (but not add a build time dependency on Abseil)? |
@g-easy - we can use Abseil's variant.h with a stub for exception handler like this.. Maybe under compile time flag that controls whether we provide it, or if Abseil provides it: #if defined(HAVE_ABSEIL)
namespace absl
{
namespace variant_internal
{
void __cdecl ThrowBadVariantAccess(){};
}
} // namespace absl
#endif At least that way we do not need to use Abseil's implementation of exception handler for header-only implementation of SDK API. I am not entirely sure if we need to use Abseil for Windows only or elsewhere too. |
I would prefer to have a single implementation of nostd::variant. Especially if we're trying to maintain ABI compat. |
Is exception handling only dependency we have as a static library ? Also, redefining
Also are there any issues in using abseil variant implementation for all the platforms. Or other way, fixing existing |
Do we have to link in Abseil or can we just borrow their variant.h and bring the exception handling in line with our requirements (which are to not require EH) |
From @maxgolov explanation, it seems to be latter - i.e, bringing abseil |
@lalitb - that's right, it's only the exception handling part (it seems). So, in theory, we should be able to consume the Abseil's header. One issue with that though - need to check if this is internal detail, and what happens if our customer also links the Abseil's real implementation of the exception handler? Then we may end up with doubly defined symbol. Something that possibly can be addressed by yet another compiler option: whether to expect the Abseil's exception handler or statically link our own within. @g-easy - we maintain ABI compatibility for particular OS. You'd expect Windows .exe to load .dll, and that .dll may use Abseil on Windows. Whereas you'd expect .bin to load .so (on Mac or Linux), and POSIX implementation may continue to use |
@lalitb - I am not against fixing our |
ContextValue
has been recently introduced in SDK. Unfortunately the twonostd::shared_ptr<...>
variant members are failing to compile with Visual Studio 2015, due to issue innostd::variant
backport.This code fails to compile:
with the following error:
whereas a simpler definition of the variant that does not use
nostd::shared_ptr
- compiles successfully:The issue is in a way how
nostd::variant
backport handles complex objects. Primitive types are OK.There could be a few alternative solutions to this issue:
raw pointers
insteadnostd::detail::visitation::base
nostd::variant
withabsl::variant
( somewhat related to [WIP] Ability to use Standard Library as a substitute for nostd:: classes #275 - ability to substitutenostd
with alternate implementation )The text was updated successfully, but these errors were encountered: