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.

alk
  • 69,737
  • 10
  • 105
  • 255
acini
  • 49
  • 1
  • 6
  • 2
    I think you need to include `` for this. I'm not sure how the include statement would look for a framework on macOS, though. – Blaze Jan 25 '19 at 15:21
  • Related to https://stackoverflow.com/q/28483819/694576 if not a dupe to it. – alk Jan 25 '19 at 15:28
  • @Blaze and indeed I get a file not found error... – acini Jan 25 '19 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 – acini Jan 25 '19 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. – Blaze Jan 25 '19 at 15:44
  • @Blaze I find different arrayobject.h... this is because with anaconda I use different environments ... but how do I tell xcode to include it? – acini Jan 25 '19 at 15:50
  • No idea, sorry. I don't have access to macOS installation right now. Perhaps you can install the library with homebrew or download the binary somewhere, although I didn't have any luck finding it. – Blaze Jan 28 '19 at 07:06

0 Answers0