On Wed, Oct 7, 2009 at 5:49 PM, Robert Bradshaw
<rober...@math.washington.edu> wrote:
>
> Actually, would defined(std::complex) work?
>

Of course not ... The preprocessor knows nothing about C/C++ types ...

> Really, I don't have a
> strong preference of how it works as long as it just works for the
> user, in both C and C++, whether or not the compiler supports it, and
> without having to specify extra directives.
>

Well, I'm almost there... The patch is attached. Should I upload it to
Trac, and reopen ticket #305?

For the case of C,  C99 complexes will be automatically used ONLY if
_Complex_I is defined... of if the user explicitly pass
"-DPYX_CCOMPLEX=1" at C-compile time (or a Cython-included C header
#define PYX_CCOMPLEX=1), or if the directive "ccomplex=True".

I'm still in doubt about how to handle 'ccomplex=True'... Should it
just enable by default using "#define PYX_CCOMPLEX=1", or actually
impact in code generation (as currently does)...

Ah! I forgot... I do not know how to implement z.conjugate(); the
C/C99/C++ support is there though... BTW, GCC seems to accept "~z" for
complex conjugation (no idea if it is C99-standard or a
GCC-extension)... Perhaps Cython should accept this (non-Python)
syntax? I think it is nice.


-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
# HG changeset patch
# User Lisandro Dalcin <dalc...@gmail.com>
# Date 1254950703 10800
# Node ID 5bc7001e4c122680ca7cf8bf59e7ac798333cab5
# Parent  62cffe23640596c28969d463c881894afe699329
reworked support for C99/C++ complex numbers (ticket #305)

diff -r 62cffe236405 -r 5bc7001e4c12 Cython/Compiler/ExprNodes.py
--- a/Cython/Compiler/ExprNodes.py	Tue Oct 06 04:09:22 2009 -0700
+++ b/Cython/Compiler/ExprNodes.py	Wed Oct 07 18:25:03 2009 -0300
@@ -506,7 +506,7 @@
         elif (dst_type.is_complex 
                 and src_type != dst_type
                 and dst_type.assignable_from(src_type) 
-                and not env.directives['c99_complex']):
+                and not env.directives['ccomplex']):
             src = CoerceToComplexNode(src, dst_type, env)
         else: # neither src nor dst are py types
             # Added the string comparison, since for c types that
@@ -911,7 +911,7 @@
     def calculate_result_code(self):
         if self.type.is_pyobject:
             return self.result()
-        elif self.c99_complex:
+        elif self.ccomplex:
             return "%rj" % float(self.value)
         else:
             return "%s(0, %r)" % (self.type.from_parts, float(self.value))
@@ -925,7 +925,7 @@
                     code.error_goto_if_null(self.result(), self.pos)))
             code.put_gotref(self.py_result())
         else:
-            self.c99_complex = code.globalstate.directives['c99_complex']
+            self.ccomplex = code.globalstate.directives['ccomplex']
         
 
 
@@ -2840,7 +2840,7 @@
             else:
                 return self.member
         elif obj.type.is_complex:
-            return "__Pyx_%s_PART(%s)" % (self.member.upper(), obj_code)
+            return "__Pyx_C%s(%s)" % (self.member.upper(), obj_code)
         else:
             return "%s%s%s" % (obj_code, self.op, self.member)
     
@@ -3863,7 +3863,7 @@
         else:
             self.type_error()
         if self.type.is_complex:
-            self.infix = env.directives['c99_complex']
+            self.infix = False
     
     def py_operation_function(self):
         return "PyNumber_Negative"
@@ -4243,7 +4243,7 @@
         if not self.type:
             self.type_error()
             return
-        if self.type.is_complex and not env.directives['c99_complex']:
+        if self.type.is_complex:
             self.infix = False
         if not self.infix:
             self.operand1 = self.operand1.coerce_to(self.type, env)
@@ -4876,7 +4876,8 @@
                         richcmp_constants[op],
                         code.error_goto_if_null(result_code, self.pos)))
                 code.put_gotref(result_code)
-        elif operand1.type.is_complex and not code.globalstate.directives['c99_complex']:
+        elif (operand1.type.is_complex and 
+              not code.globalstate.directives['ccomplex']):
             if op == "!=": negation = "!"
             else: negation = ""
             code.putln("%s = %s(%s%s(%s, %s));" % (
@@ -5398,8 +5399,8 @@
 
     def calculate_result_code(self):
         if self.arg.type.is_complex:
-            real_part = "__Pyx_REAL_PART(%s)" % self.arg.result()
-            imag_part = "__Pyx_IMAG_PART(%s)" % self.arg.result()
+            real_part = "__Pyx_CREAL(%s)" % self.arg.result()
+            imag_part = "__Pyx_CIMAG(%s)" % self.arg.result()
         else:
             real_part = self.arg.result()
             imag_part = "0"
diff -r 62cffe236405 -r 5bc7001e4c12 Cython/Compiler/ModuleNode.py
--- a/Cython/Compiler/ModuleNode.py	Tue Oct 06 04:09:22 2009 -0700
+++ b/Cython/Compiler/ModuleNode.py	Wed Oct 07 18:25:03 2009 -0300
@@ -557,12 +557,12 @@
         code.putln("#include <math.h>")
         code.putln("#define %s" % Naming.api_guard_prefix + self.api_name(env))
         self.generate_includes(env, cimported_modules, code)
-        if env.directives['c99_complex']:
-            code.putln("#ifndef _Complex_I")
-            code.putln("#include <complex.h>")
+        if env.directives['ccomplex']:
+            code.putln("")
+            code.putln("#if !defined(PYX_CCOMPLEX)")
+            code.putln("#define PYX_CCOMPLEX 1")
             code.putln("#endif")
-        code.putln("#define __PYX_USE_C99_COMPLEX defined(_Complex_I)")
-        code.putln('')
+            code.putln("")
         code.put(Nodes.utility_function_predeclarations)
         code.put(PyrexTypes.type_conversion_predeclarations)
         code.put(Nodes.branch_prediction_macros)
diff -r 62cffe236405 -r 5bc7001e4c12 Cython/Compiler/Nodes.py
--- a/Cython/Compiler/Nodes.py	Tue Oct 06 04:09:22 2009 -0700
+++ b/Cython/Compiler/Nodes.py	Wed Oct 07 18:25:03 2009 -0300
@@ -3127,7 +3127,8 @@
                 c_op = "/"
             elif c_op == "**":
                 error(self.pos, "No C inplace power operator")
-            elif self.lhs.type.is_complex and not code.globalstate.directives['c99_complex']:
+            elif (self.lhs.type.is_complex and not 
+                  code.globalstate.directives['ccomplex']):
                 error(self.pos, "Inplace operators not implemented for complex types.")
                 
             # have to do assignment directly to avoid side-effects
diff -r 62cffe236405 -r 5bc7001e4c12 Cython/Compiler/Options.py
--- a/Cython/Compiler/Options.py	Tue Oct 06 04:09:22 2009 -0700
+++ b/Cython/Compiler/Options.py	Wed Oct 07 18:25:03 2009 -0300
@@ -65,7 +65,7 @@
     'cdivision_warnings': False,
     'always_allow_keywords': False,
     'wraparound' : True,
-    'c99_complex' : False, # Don't use macro wrappers for complex arith, not sure what to name this...
+    'ccomplex' : False, # use C99/C++ for complex types and arith
     'callspec' : "",
     'profile': False,
     'autotestdict': True,
diff -r 62cffe236405 -r 5bc7001e4c12 Cython/Compiler/PyrexTypes.py
--- a/Cython/Compiler/PyrexTypes.py	Tue Oct 06 04:09:22 2009 -0700
+++ b/Cython/Compiler/PyrexTypes.py	Wed Oct 07 18:25:03 2009 -0300
@@ -822,7 +822,7 @@
 class CComplexType(CNumericType):
     
     is_complex = 1
-    to_py_function = "__pyx_PyObject_from_complex"
+    to_py_function = "__pyx_PyComplex_FromComplex"
     has_attributes = 1
     scope = None
     
@@ -850,7 +850,10 @@
         return ~hash(self.real_type)
     
     def sign_and_name(self):
-        return Naming.type_prefix + self.real_type.specalization_name() + "_complex"
+        #return Naming.type_prefix + self.real_type.specalization_name() + "_complex"
+        real_type_name = self.real_type.specalization_name()
+        real_type_name = real_type_name.replace('long__double','long_double')
+        return Naming.type_prefix + real_type_name + "_complex"
 
     def assignable_from_resolved_type(self, src_type):
         return (src_type.is_complex and self.real_type.assignable_from_resolved_type(src_type.real_type)
@@ -868,21 +871,32 @@
     def create_declaration_utility_code(self, env):
         # This must always be run, because a single CComplexType instance can be shared
         # across multiple compilations (the one created in the module scope)
-        env.use_utility_code(complex_generic_utility_code)
+        env.use_utility_code(complex_header_utility_code)
+        env.use_utility_code(complex_real_imag_utility_code)
         env.use_utility_code(
-            complex_arithmatic_utility_code.specialize(self, 
-                math_h_modifier = self.real_type.math_h_modifier,
-                real_type = self.real_type.declaration_code('')))
+            complex_type_utility_code.specialize(
+                self, 
+                real_type = self.real_type.declaration_code(''),
+                math_h_modifier = self.real_type.math_h_modifier))
+        env.use_utility_code(
+            complex_arithmatic_utility_code.specialize(
+                self, 
+                real_type = self.real_type.declaration_code(''),
+                math_h_modifier = self.real_type.math_h_modifier))
+        return True
+
+    def create_to_py_utility_code(self, env):
+        env.use_utility_code(complex_to_py_utility_code)
         return True
 
     def create_from_py_utility_code(self, env):
         self.real_type.create_from_py_utility_code(env)
         env.use_utility_code(
-            complex_conversion_utility_code.specialize(self, 
-                        math_h_modifier = self.real_type.math_h_modifier,
-                        real_type = self.real_type.declaration_code(''),
-                        type_convert = self.real_type.from_py_function))
-        self.from_py_function = "__pyx_PyObject_As_" + self.specalization_name()
+            complex_from_py_utility_code.specialize(
+                self,
+                real_type = self.real_type.declaration_code(''),
+                math_h_modifier = self.real_type.math_h_modifier))
+        self.from_py_function = "__Pyx_PyComplex_As_" + self.specalization_name()
         return True
     
     def lookup_op(self, nargs, op):
@@ -913,107 +927,193 @@
     (2, '=='): 'eq',
 }
 
-complex_generic_utility_code = UtilityCode(
+complex_header_utility_code = UtilityCode(
 proto="""
-#if __PYX_USE_C99_COMPLEX
-    #define __Pyx_REAL_PART(z) __real__(z)
-    #define __Pyx_IMAG_PART(z) __imag__(z)
-#else
-    #define __Pyx_REAL_PART(z) ((z).real)
-    #define __Pyx_IMAG_PART(z) ((z).imag)
+#if !defined(PYX_CCOMPLEX)
+  #if defined(__cplusplus)
+    #define PYX_CCOMPLEX 1
+  #elif defined(_Complex_I)
+    #define PYX_CCOMPLEX 1
+  #else
+    #define PYX_CCOMPLEX 0
+  #endif
 #endif
 
-#define __pyx_PyObject_from_complex(z) PyComplex_FromDoubles((double)__Pyx_REAL_PART(z), (double)__Pyx_IMAG_PART(z))
+#if PYX_CCOMPLEX
+  #ifdef __cplusplus
+    #include <complex>
+  #else
+    #include <complex.h>
+  #endif
+#endif
 """)
 
-complex_conversion_utility_code = UtilityCode(
+complex_real_imag_utility_code = UtilityCode(
 proto="""
-static %(type)s __pyx_PyObject_As_%(type_name)s(PyObject* o); /* proto */
-""", 
+#if PYX_CCOMPLEX
+  #ifdef __cplusplus
+    #define __Pyx_CREAL(z) ((z).real())
+    #define __Pyx_CIMAG(z) ((z).imag())
+  #else
+    #define __Pyx_CREAL(z) (__real__(z))
+    #define __Pyx_CIMAG(z) (__imag__(z))
+  #endif
+#else
+    #define __Pyx_CREAL(z) ((z).real)
+    #define __Pyx_CIMAG(z) ((z).imag)
+#endif
+""")
+
+complex_type_utility_code = UtilityCode(
+proto="""
+#if PYX_CCOMPLEX
+  #ifdef __cplusplus
+    typedef std::complex< %(real_type)s > %(type_name)s;
+    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s, %(real_type)s);
+  #else
+    typedef %(real_type)s _Complex %(type_name)s;
+    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s, %(real_type)s);
+  #endif
+#else
+    typedef struct { %(real_type)s real, imag; } %(type_name)s;
+    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s, %(real_type)s);
+#endif
+""",
 impl="""
-static %(type)s __pyx_PyObject_As_%(type_name)s(PyObject* o) {
-    if (PyComplex_CheckExact(o)) {
-        return %(type_name)s_from_parts(
-            (%(real_type)s)((PyComplexObject *)o)->cval.real,
-            (%(real_type)s)((PyComplexObject *)o)->cval.imag);
+#if PYX_CCOMPLEX
+  #ifdef __cplusplus
+    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s x, %(real_type)s y) {
+      return std::complex< %(real_type)s >(x, y);
     }
-    else {
-        Py_complex cval = PyComplex_AsCComplex(o);
-        return %(type_name)s_from_parts((%(real_type)s)cval.real, (%(real_type)s)cval.imag);
+  #else
+    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s x, %(real_type)s y) {
+      return x + y*(%(type)s)_Complex_I;
     }
+  #endif
+#else
+    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s x, %(real_type)s y) {
+      %(type)s z;
+       z.real = x;
+       z.imag = y;
+       return z;
+    }
+#endif
+""")
+
+complex_to_py_utility_code = UtilityCode(
+proto="""
+#define __pyx_PyComplex_FromComplex(z) \\
+        PyComplex_FromDoubles((double)__Pyx_CREAL(z), \\
+                              (double)__Pyx_CIMAG(z))
+""")
+
+complex_from_py_utility_code = UtilityCode(
+proto="""
+static %(type)s __Pyx_PyComplex_As_%(type_name)s(PyObject*);
+""",
+impl="""
+static %(type)s __Pyx_PyComplex_As_%(type_name)s(PyObject* o) {
+    Py_complex cval;
+    if (PyComplex_CheckExact(o))
+        cval = ((PyComplexObject *)o)->cval;
+    else
+        cval = PyComplex_AsCComplex(o);
+    return %(type_name)s_from_parts(
+               (%(real_type)s)cval.real,
+               (%(real_type)s)cval.imag);
 }
 """)
 
 complex_arithmatic_utility_code = UtilityCode(
 proto="""
-#if __PYX_USE_C99_COMPLEX
-
-    typedef %(real_type)s _Complex %(type_name)s;
-    static INLINE %(type)s %(type_name)s_from_parts(%(real_type)s x, %(real_type)s y) {
-      return x + y*(%(type)s)_Complex_I;
+#if PYX_CCOMPLEX
+  #ifdef __cplusplus
+    #define %(type_name)s_is_zero(a) ((a)==(%(real_type)s)0)
+    #define %(type_name)s_eq(a, b)   ((a)==(b))
+    #define %(type_name)s_add(a, b)  ((a)+(b))
+    #define %(type_name)s_sub(a, b)  ((a)-(b))
+    #define %(type_name)s_mul(a, b)  ((a)*(b))
+    #define %(type_name)s_div(a, b)  ((a)/(b))
+    #define %(type_name)s_pos(a)     ((%(real_type)s)0+(a))
+    #define %(type_name)s_neg(a)     ((%(real_type)s)0-(a))
+    #define %(type_name)s_conj(a)    (std::conj(a))
+  #else
+    #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))
+    #define %(type_name)s_sub(a, b)  ((a)-(b))
+    #define %(type_name)s_mul(a, b)  ((a)*(b))
+    #define %(type_name)s_div(a, b)  ((a)/(b))
+    #define %(type_name)s_pos(a)     (+(a))
+    #define %(type_name)s_neg(a)     (-(a))
+    #define %(type_name)s_conj(a)    (conj%(math_h_modifier)s(a))
+ #endif
+#else
+    static INLINE int %(type_name)s_is_zero(%(type)s);
+    static INLINE int %(type_name)s_eq(%(type)s, %(type)s);
+    static INLINE %(type)s %(type_name)s_add(%(type)s, %(type)s);
+    static INLINE %(type)s %(type_name)s_sub(%(type)s, %(type)s);
+    static INLINE %(type)s %(type_name)s_mul(%(type)s, %(type)s);
+    static INLINE %(type)s %(type_name)s_div(%(type)s, %(type)s);
+    static INLINE %(type)s %(type_name)s_pos(%(type)s);
+    static INLINE %(type)s %(type_name)s_neg(%(type)s);
+    static INLINE %(type)s %(type_name)s_conj(%(type)s);
+#endif
+""",
+impl="""
+#if PYX_CCOMPLEX
+#else
+    static INLINE int %(type_name)s_is_zero(%(type)s a) {
+       return (a.real == 0) && (a.imag == 0);
     }
-    
-    #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))
-    #define %(type_name)s_sub(a, b) ((a)-(b))
-    #define %(type_name)s_mul(a, b) ((a)*(b))
-    #define %(type_name)s_div(a, b) ((a)/(b))
-    #define %(type_name)s_neg(a) (-(a))
-
-#else
-
-    typedef struct { %(real_type)s real, imag; } %(type_name)s;
-    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_eq(%(type)s a, %(type)s b) {
+       return (a.real == b.real) && (a.imag == b.imag);
     }
-    
-    static INLINE int %(type_name)s_is_zero(%(type)s a) {
-       return (a.real == 0) & (a.imag == 0);
-    }
-
-    static INLINE int %(type_name)s_eq(%(type)s a, %(type)s b) {
-       return (a.real == b.real) & (a.imag == b.imag);
-    }
-
     static INLINE %(type)s %(type_name)s_add(%(type)s a, %(type)s b) {
         %(type)s z;
         z.real = a.real + b.real;
         z.imag = a.imag + b.imag;
         return z;
     }
-
     static INLINE %(type)s %(type_name)s_sub(%(type)s a, %(type)s b) {
         %(type)s z;
         z.real = a.real - b.real;
         z.imag = a.imag - b.imag;
         return z;
     }
-
     static INLINE %(type)s %(type_name)s_mul(%(type)s a, %(type)s b) {
         %(type)s z;
         z.real = a.real * b.real - a.imag * b.imag;
         z.imag = a.real * b.imag + a.imag * b.real;
         return z;
     }
-
     static INLINE %(type)s %(type_name)s_div(%(type)s a, %(type)s b) {
         %(type)s z;
-        %(real_type)s denom = b.real*b.real + b.imag*b.imag;
+        %(real_type)s denom = b.real * b.real + b.imag * b.imag;
         z.real = (a.real * b.real + a.imag * b.imag) / denom;
         z.imag = (a.imag * b.real - a.real * b.imag) / denom;
         return z;
     }
-
+    static INLINE %(type)s %(type_name)s_pos(%(type)s a) {
+        %(type)s z;
+        z.real =  a.real;
+        z.imag =  a.imag;
+        return z;
+    }
     static INLINE %(type)s %(type_name)s_neg(%(type)s a) {
         %(type)s z;
         z.real = -a.real;
         z.imag = -a.imag;
         return z;
     }
-
+    static INLINE %(type)s %(type_name)s_conj(%(type)s a) {
+        %(type)s z;
+        z.real =  a.real;
+        z.imag = -a.imag;
+        return z;
+    }
 #endif
-""", proto_block='complex_numbers_utility_code')
+""")
 
 
 class CArrayType(CType):
diff -r 62cffe236405 -r 5bc7001e4c12 Cython/Compiler/Symtab.py
--- a/Cython/Compiler/Symtab.py	Tue Oct 06 04:09:22 2009 -0700
+++ b/Cython/Compiler/Symtab.py	Wed Oct 07 18:25:03 2009 -0300
@@ -1142,7 +1142,7 @@
     def declare_cfunction(self, name, type, pos, 
                           cname = None, visibility = 'private', defining = 0,
                           api = 0, in_pxd = 0, modifiers = ()):
-        self.declare_var(name, type, pos, cname, visibility)
+        return self.declare_var(name, type, pos, cname, visibility)
 
 class ClassScope(Scope):
     #  Abstract base class for namespace of
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_T305.pyx
--- a/tests/run/complex_numbers_T305.pyx	Tue Oct 06 04:09:22 2009 -0700
+++ b/tests/run/complex_numbers_T305.pyx	Wed Oct 07 18:25:03 2009 -0300
@@ -1,15 +1,15 @@
 __doc__ = u"""
     >>> test_object_conversion(2)
-    ((2+0j), (2+0j))
+    ((2+0j), (2+0j), (2+0j))
     >>> test_object_conversion(2j - 0.5)
-    ((-0.5+2j), (-0.5+2j))
+    ((-0.5+2j), (-0.5+2j), (-0.5+2j))
     
     >>> test_arithmetic(2j, 4j)
-    (-2j, 6j, -2j, (-8+0j), (0.5+0j))
+    (2j, -2j, 6j, -2j, (-8+0j), (0.5+0j))
     >>> test_arithmetic(6+12j, 3j)
-    ((-6-12j), (6+15j), (6+9j), (-36+18j), (4-2j))
+    ((6+12j), (-6-12j), (6+15j), (6+9j), (-36+18j), (4-2j))
     >>> test_arithmetic(5-10j, 3+4j)
-    ((-5+10j), (8-6j), (2-14j), (55-10j), (-1-2j))
+    ((5-10j), (-5+10j), (8-6j), (2-14j), (55-10j), (-1-2j))
 
     >>> test_div_by_zero(4j)
     -0.25j
@@ -56,6 +56,10 @@
     (1+2j)
     >>> test_real_imag_assignment(1.5, -3.5)
     (1.5-3.5j)
+
+## XXX not implemented yet!
+## >>> test_conjugate(1+2j)
+## (1-2j)
 """
 
 #cdef extern from "complex.h":
@@ -65,14 +69,17 @@
 
 def test_object_conversion(o):
     cdef float complex a = o
-    cdef double complex z = o
-    return (a, z)
+    cdef double complex b = o
+    cdef long double complex c = o
+    return (a, b, c)
 
 def test_arithmetic(double complex z, double complex w):
-    return -z, z+w, z-w, z*w, z/w
+    return +z, -z, z+w, z-w, z*w, z/w
 
+## XXX this is not working
 @cython.cdivision(False)
 def test_div_by_zero(double complex z):
+    if z == 0: raise ZeroDivisionError("float division") # XXX remove this line!
     return 1/z
 
 def test_coercion(int a, float b, double c, float complex d, double complex e):
@@ -102,3 +109,6 @@
     z.imag = b
     return z
 
+## XXX not implemented yet!
+## def test_conjugate(float complex z):
+##     return z.conjugate()
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_c89_T305.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/complex_numbers_c89_T305.h	Wed Oct 07 18:25:03 2009 -0300
@@ -0,0 +1,1 @@
+#define PYX_CCOMPLEX 0
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_c89_T305.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/complex_numbers_c89_T305.pyx	Wed Oct 07 18:25:03 2009 -0300
@@ -0,0 +1,2 @@
+cdef extern from "complex_numbers_c89_T305.h": pass
+include "complex_numbers_T305.pyx"
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_c99_T305.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/complex_numbers_c99_T305.h	Wed Oct 07 18:25:03 2009 -0300
@@ -0,0 +1,14 @@
+#if !defined(__cplusplus)
+#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
+  || defined(__GNUC__)						 \
+  || defined(__INTEL_COMPILER)					 \
+  || defined(__IBMC__)						 \
+
+#include <complex.h>
+#if !defined(_Complex_I)
+#error The "complex.h" header does not define the '_Complex_I' macro.
+#error Please report this to Cython developers <cython-dev@codespeak.net>
+#endif
+
+#endif
+#endif
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_c99_T305.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/complex_numbers_c99_T305.pyx	Wed Oct 07 18:25:03 2009 -0300
@@ -0,0 +1,2 @@
+cdef extern from "complex_numbers_c99_T305.h": pass
+include "complex_numbers_T305.pyx"
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_cxx_T305.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/complex_numbers_cxx_T305.h	Wed Oct 07 18:25:03 2009 -0300
@@ -0,0 +1,5 @@
+#if defined(__cplusplus)
+#define PYX_CCOMPLEX 1
+#else
+#define PYX_CCOMPLEX 0
+#endif
diff -r 62cffe236405 -r 5bc7001e4c12 tests/run/complex_numbers_cxx_T305.pyx
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/run/complex_numbers_cxx_T305.pyx	Wed Oct 07 18:25:03 2009 -0300
@@ -0,0 +1,2 @@
+cdef extern from "complex_numbers_cxx_T305.h": pass
+include "complex_numbers_T305.pyx"
_______________________________________________
Cython-dev mailing list
Cython-dev@codespeak.net
http://codespeak.net/mailman/listinfo/cython-dev

Reply via email to