[libcxx-commits] [libcxx] [libc++] Fix hypotf linker error with Clang modules on Windows UCRT (PR #209403)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jul 14 02:53:03 PDT 2026
================
@@ -27,19 +27,35 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
+#if defined(_LIBCPP_MSVCRT)
+extern "C" {
+_LIBCPP_CRT_FUNC float __cdecl _hypotf(float, float);
+}
+#endif
+
_LIBCPP_BEGIN_NAMESPACE_STD
namespace __math {
-inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT { return __builtin_hypotf(__x, __y); }
+inline _LIBCPP_HIDE_FROM_ABI float hypot(float __x, float __y) _NOEXCEPT {
+#if defined(_LIBCPP_MSVCRT)
+ return ::_hypotf(__x, __y);
+#else
+ return __builtin_hypotf(__x, __y);
+#endif
+}
template <class = int>
_LIBCPP_HIDE_FROM_ABI double hypot(double __x, double __y) _NOEXCEPT {
return __builtin_hypot(__x, __y);
}
inline _LIBCPP_HIDE_FROM_ABI long double hypot(long double __x, long double __y) _NOEXCEPT {
+#if defined(_LIBCPP_MSVCRT)
+ return (long double)__math::hypot((double)__x, (double)__y);
----------------
frederick-vs-ja wrote:
Also, do we want to explicitly cast a `double` value to `long double` given the conversion is widening?
https://github.com/llvm/llvm-project/pull/209403
More information about the libcxx-commits
mailing list