17

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.)

Fred Foo
  • 355,277
  • 75
  • 744
  • 836
  • For what it's worth, I get the same warning. No idea how to fix it though. – Snorfalorpagus Jan 09 '13 at 16:23
  • I have a [Cython post](http://stackoverflow.com/questions/41944883/verifying-compatibility-in-compiling-extension-types-and-using-them-with-cdef) you may be able to provide insight on. – ballade4op52 Jan 31 '17 at 20:52

2 Answers2

5

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.

voithos
  • 68,482
  • 12
  • 101
  • 116
  • I have a [Cython post](http://stackoverflow.com/questions/41944883/verifying-compatibility-in-compiling-extension-types-and-using-them-with-cdef) you may be able to provide insight on. – ballade4op52 Jan 31 '17 at 20:51
0

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 ;)

SpankMe
  • 836
  • 1
  • 8
  • 23