From cfbaba79a2dd380e580a247b8fd36af60c878e8f Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 13 Nov 2012 01:31:49 +0100 Subject: complex: add C11 CMPLX macros and replace cpack with them --- include/complex.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/complex.h b/include/complex.h index b4bcb22e..8206e026 100644 --- a/include/complex.h +++ b/include/complex.h @@ -112,6 +112,15 @@ long double creall(long double complex); #define cimagf(x) __CIMAG(x, float) #define cimagl(x) __CIMAG(x, long double) +#define __CMPLX(x, y, t) \ + ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z) + +#if __STDC_VERSION__ >= 201112L +#define CMPLX(x, y) __CMPLX(x, y, double) +#define CMPLXF(x, y) __CMPLX(x, y, float) +#define CMPLXL(x, y) __CMPLX(x, y, long double) +#endif + #ifdef __cplusplus } #endif -- cgit v1.2.1