SWIG+c+Python: Passing and receiving c arrays
I am trying to reuse some old c code with SWIG and Python. Right now I am quite confused. The errors I get can be demonstrated on a small example: bsp.h: extern void add(int a[], int b[], int c[]); bsp.c: #include "bsp.h" void add(int a[], int b[], int c[]) { c[0] = a[0] + b[0]; c[1] = a[1] + b[1]; } bsp.i %module bsp %{ #include "bsp.h"; %} %include "bsp.h"; setup.py: #!/usr/bin/env python from distutils.core import setup, Extension bsp_module = Extension('_bsp', sources = ['bsp_wrap.c', 'bsp.c'] ) setup(name = 'bsp', ext_modules = [bsp_module], py_modules = ["bsp"] ) The example Python file