about summary refs log tree commit diff
path: root/include/complex.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/complex.h')
-rw-r--r--include/complex.h9
1 files changed, 9 insertions, 0 deletions
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