When compiling a bunch of Cython-generated C files that interface with Numpy, I get the warning:
/usr/lib/pymodules/python2.7/numpy/core/include/numpy/__ufunc_api.h:226:1: warning: ‘_import_umath’ defined but not used [-Wunused-function]
I can't seem to get rid of that. Figuring this might be similar to np.import_array()
, which gets rid of a related warning (and is actually required for using the Numpy C API), I tried np.import_umath()
at top level, but the warning persists. How do I get rid of it?
(Cython 0.17.4, Numpy 1.6.2.)
There's a thread on the Cython mailing list that discusses this a little bit. I believe that the discussion was concerning the Cython test suite, but I think the same ideas can be applied to generated files.
In essence, the issue involved a hack that was done in order to avoid C compiler warnings about unused functions.
The code file in question currently looks like this:
cdef extern from *:
bint FALSE "0"
void import_array()
# void import_umath()
if FALSE:
import_array()
# import_umath()
In the past, the import_umath()
portions were uncommented, but as it turns out, this was causing errors when building in C++ mode. So it appears that it was decided that a compiler warning is much better than a broken build.
In short, it seems this particular warning exists for the sake of C++ compatibility, and can be safely ignored. I suppose if you really dislike it, and if you're building in C mode, then you could try to do the same hack, by importing a similar .pxi
file with a call to import_umath()
inside of your Cython code.
Well, what it says, is that there's a function in the code, that's declared but not used, so perhaps its obsolete and shouldnt be there. Since its just a warning, and not very dangerous one (unless you'll leave a lot of such functions, clobbering the code, increasing ram usage, binary size and so on) I would simply ignore it - most probably its not worth your time ;)