-
Notifications
You must be signed in to change notification settings - Fork 451
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
Need fine-grained HAVE_CPP_STDLIB #1071
Comments
I think the switches could be smarter to automatically detect the value from built-in macros & pragmas. And we provide some switches for user overridings.
I personally would prefer STD->Abseil/GSL->Non-STD. |
It's encouraged to always use non-std libraries to maintain ABI compatibility ( https://github.com/open-telemetry/opentelemetry-cpp/blob/main/docs/abi-policy.md#application-binary-interface-abi-policy ). While there are macros switches provided to use other libraries, their use is discouraged. These switches were provided as in the past there were issues reported during compilation with these non-std, but I believe they all should be fixed now. |
Do we have a use case why do we want to enable the STL components individually? |
|
It's good to maintain ABI compatibility. If we provide such switches, we could still make the default setting ABI compatible. |
For the suggested flag like |
check_cxx_source_compiles(
"
#include <iostream>
#include <string_view>
int main() {
constexpr std::string_view unicode[] {\"▀▄─\", \"▄▀─\", \"▀─▄\", \"▄─▀\"};
for (int y{}, p{}; y != 6; ++y, p = ((p + 1) % 4)) {
for (int x{}; x != 16; ++x)
std::cout << unicode[p];
std::cout << std::endl;
}
return 0;
}"
LIBATFRAME_UTILS_TEST_STL_STRING_VIEW) We use these cmake scripts to test With C++20 and upper, we can also use
|
This issue was marked as stale due to lack of activity. It will be closed in 7 days if no furthur activity occurs. |
Trying to use opentelemetry-cpp on several platforms, which have varying degrees of STL support, I am facing the same issues. Currently:
Proposal for a fix: In CMake, change the option to:
Use pre processor symbols like:
When a feature is not available in the STL library, for example when building WITH_STL=CXX17, alternate implementations needed to satisfy nostd can be chosen depending on WITH_GSL, as currently for nostd::span. For example, Building with WITH_STL=CXX17 will define the following symbols:
which means that:
but nostd::span will not use the STL (available in C++20 only) As for individual flags, like The assumption is that if a STL implement all C++11 features, there should be no need to pick STD_SHARED_PTR independently from STD_UNIQUE_PTR. Same for any STL flavor. |
I had to declare HAVE_CPP_STDLIB top-level for projects using OpenTelemetry, and wished it was prefixed with OPENTELEMETRY_, and then split if needed (suggested above). So I would love to see this coming - OPENTELEMETRY_HAVE_CXXnn - then it'll make sense for us to have these declared top-level somewhere, otherwise it seems unclean (unlikely to break things for us, but who knows if another OSS project usese HAVE_CPP_STDLIB) |
Is your feature request related to a problem?
The
std::shared_ptr
&std::unique_ptr
are well-supported by wide-spread compilers in c++11, whilestd::string_view
&std::variant
are unavailable until c++17. We currently use a coarse-grained switchHAVE_CPP_STDLIB
to control all these things. As a result, we cannot enable any of them.Using our private implemented
nonstd::shared_ptr
would lead to interoperability issue withstd::shared_ptr
, which is quite annoying.Describe the solution you'd like
I'd like to split
HAVE_CPP_STDLIB
into more fine-grained switches:Describe alternatives you've considered
Didn't find a better approach.
The text was updated successfully, but these errors were encountered: