Piotr Caban (@piotr) commented about libs/musl/src/internal/complex_impl.h:
+#ifndef _COMPLEX_IMPL_H +#define _COMPLEX_IMPL_H
+#include <complex.h> +#include "libm.h"
+#undef __CMPLX +#undef CMPLX +#undef CMPLXF +#undef CMPLXL
+#define __CMPLX(x, y, t) \
- ((union { t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z)
While this code does what you want it looks non portable / over complicated. At least __xy type should be changed to something like: ```c #define __CMPLX(x, y, t, t2) \ ((union { t __z; t2 __xy[2]; }){.__xy = {(x),(y)}}.__z)
#define CMPLX(x, y) __CMPLX(x, y, _Dcomplex, double) ``` It could be simplified even further to: ```c #define __CMPLX(x, y, t) ((t){(x), (y)}) ```
I'm afraid that none of this code is portable (at least it will not compile with MSVC).