On Mon Apr 7 10:02:30 2025 +0000, Piotr Caban wrote:
While this code does what you want it looks non portable / over complicated. At least __xy type should be changed to something like:
#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:
#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).
It's probably best to define the macros using `_Cbuild` and `_FCbuild` functions: ```c #define CMPLX(x, y) _Cbuild(x, y) ```