[libc-commits] [libc] [libc] Implement CMPLX related macros (PR #156344)
Connector Switch via libc-commits
libc-commits at lists.llvm.org
Thu Sep 4 01:51:31 PDT 2025
================
@@ -19,6 +21,18 @@
// TODO: Add imaginary macros once GCC or Clang support _Imaginary builtin-type.
+#define CMPLX(x, y) __builtin_complex((double)(x), (double)(y))
+#define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y))
+#define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y))
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
----------------
c8ef wrote:
Yes, I can do this, but I'm wondering how we should correctly define the check. The issue is that using `_Complex Float16` works fine, but initialization using `__builtin_complex` is problematic. I haven't found a way to check this syntactically yet.
If we add a compiler version guard in cfloat16.h, I'm not sure we should bump the minimum Clang version to 22, since it hasn't been released yet and this may not be acceptable. If we do go this route, I think we should also kick off a build for apt.llvm.org/clang22 so we have at least one CI to test float16 support (though I'm not sure how to configure this - the last build was on 08/12).
https://github.com/llvm/llvm-project/pull/156344
More information about the libc-commits
mailing list