From 1b8bb1bfbfa65af8096ff4794f0383aa6b787a4c Mon Sep 17 00:00:00 2001 From: Dag Sverre Seljebotn Date: Wed, 20 May 2009 14:44:08 +0200 Subject: [PATCH] Do not use C99 compound literals (enables compilation on g++ 4.2.4) --- Cython/Compiler/PyrexTypes.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index f01b5174..590a6a95 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -830,8 +830,10 @@ proto=""" #if __PYX_USE_C99_COMPLEX typedef %(real_type)s _Complex %(type_name)s; - #define %(type_name)s_from_parts(x, y) ((x) + (y)*(%(type)s)_Complex_I) - + static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s x, %(real_type)s y) { + return x + y*(%(type)s)_Complex_I; + } + #define %(type_name)s_is_zero(a) ((a) == 0) #define %(type_name)s_eq(a, b) ((a) == (b)) #define %(type_name)s_add(a, b) ((a)+(b)) @@ -843,8 +845,10 @@ proto=""" #else typedef struct { %(real_type)s real, imag; } %(type_name)s; - #define %(type_name)s_from_parts(x, y) ((%(type_name)s){(%(real_type)s)x, (%(real_type)s)y}) - + static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s x, %(real_type)s y) { + %(type)s c; c.real = x; c.imag = y; return c; + } + static INLINE int %(type_name)s_is_zero(%(type)s a) { return (a.real == 0) & (a.imag == 0); } -- 2.26.2