1

I'm trying to write a library in C which take in inputs a list of numpy array following the answer of this Calling C from Python: passing list of numpy pointers post. In my header file I include:

#include <Python/Python.h> 

but when I call:

PyArray_DATA(PyList_GetItem(list,i)) 

where i is an index that runs over the list's elements, I get a compilation error:

Implicit declaration of function 'PyArray_DATA' is invalid in C99

How can I fix it?

My xcode version is 10.1. I work with a script in Python 3.5 where my list of numpy array is created and use swig to interface with my C library.

7
  • 2
    I think you need to include <numpy/arrayobject.h> for this. I'm not sure how the include statement would look for a framework on macOS, though. Commented Jan 25, 2019 at 15:21
  • Related to stackoverflow.com/q/28483819/694576 if not a dupe to it. Commented Jan 25, 2019 at 15:28
  • @Blaze and indeed I get a file not found error... Commented Jan 25, 2019 at 15:35
  • @alk I'm sorry but I don't know c++ so I have a some difficulties in understanding your link and the solution... and moreover, as I wrote, I'm not able to include numpy header files which seems to be needed in that answer too Commented Jan 25, 2019 at 15:40
  • Try browsing the Python framework on macOS and see if arrayobject.h is in there somewhere. The numpy libraries might already be included in the framework by default. Commented Jan 25, 2019 at 15:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.