lcalc: use libc++-compatible way of extending namespace std (#370545)

This commit is contained in:
Mauricio Collares
2025-01-04 14:08:13 +01:00
committed by GitHub
2 changed files with 32 additions and 6 deletions
+30
View File
@@ -0,0 +1,30 @@
diff --git a/src/libLfunction/Lcomplex.h b/src/libLfunction/Lcomplex.h
index 363bbf4..ffecd70 100644
--- a/src/libLfunction/Lcomplex.h
+++ b/src/libLfunction/Lcomplex.h
@@ -56,8 +56,11 @@
#include <cmath>
#include <sstream>
-namespace std
-{
+#ifdef _LIBCPP_VERSION
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
+namespace std {
+#endif
// Forward declarations
template<typename _Tp> class complex;
template<> class complex<float>;
@@ -1193,6 +1196,10 @@ namespace std
inline
complex<long double>::complex(const complex<double>& __z)
: _M_value(_ComplexT(__z._M_value)) { }
-} // namespace std
+#ifdef _LIBCPP_VERSION
+_LIBCPP_END_NAMESPACE_STD
+#else
+}
+#endif
#endif /* _CPP_COMPLEX */
+2 -6
View File
@@ -19,13 +19,9 @@ stdenv.mkDerivation rec {
hash = "sha256-RxWZ7T0I9zV7jUVnL6jV/PxEoU32KY7Q1UsOL5Lonuc=";
};
# workaround for vendored GCC 3.5 <complex>
# workaround for vendored GCC <complex> on libc++
# https://gitlab.com/sagemath/lcalc/-/issues/16
env.NIX_CFLAGS_COMPILE = toString [
"-D_GLIBCXX_COMPLEX"
"-D_LIBCPP_COMPLEX"
"-D_LIBCPP___FWD_COMPLEX_H"
];
patches = [ ./libcxx-compat.patch ];
nativeBuildInputs = [
autoreconfHook