robertwb / issues-import-test

0 stars 0 forks source link

Illegal C code generated with numpy complex type #112

Open robertwb opened 7 years ago

robertwb commented 7 years ago

Reported by jdemeyer on 12 May 2016 08:26 UTC The Cython module

cimport numpy as np

cdef np.float64_t x
cdef np.complex128_t y

cdef foo(self):
    return x / y

gives compiler warnings

...: implicit declaration of function fabs_npy_float64 [        } else if (fabs_npy_float64(b.real) >= fabs_npy_float64(b.imag)) {
         ^
...: implicit declaration of function hypot_npy_float64 [-Wimplicit-function-declaration](-Wimplicit-function-declaration]
)
             return hypot_npy_float64(z.real, z.imag);
             ^
...: implicit declaration of function atan2_npy_float64 [                theta = atan2_npy_float64(a.imag, a.real);
                 ^
...: implicit declaration of function log_npy_float64 [-Wimplicit-function-declaration](-Wimplicit-function-declaration]
)
             lnr = log_npy_float64(r);
             ^
...: implicit declaration of function exp_npy_float64 [            z_r = exp_npy_float64(lnr * b.real - theta * b.imag);
             ^
...: implicit declaration of function cos_npy_float64 [-Wimplicit-function-declaration](-Wimplicit-function-declaration]
)
             z.real = z_r * cos_npy_float64(z_theta);
             ^
...: implicit declaration of function sin_npy_float64 [-Wimplicit-function-declaration]
             z.imag = z_r * sin_npy_float64(z_theta);
             ^

and an error when imported:

ImportError: .../cybug.so: undefined symbol: fabs_npy_float64

The import error is a regression since Cython 0.24, the compiler warnings are also in the released Cython 0.24.

Migrated-From: http://trac.cython.org/ticket/879

robertwb commented 7 years ago

Comment by jdemeyer on 12 May 2016 08:48 UTC Compiling this as C++ code works around the problem.