Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrapping c++ struct template using cython

Tags:

I am attempting to access the struct

template <int dim> struct Data {    double X[dim];   double Val[dim]; };  

in cython. I was guessing the correct syntax should be something like:

cdef extern from "Lib.h" namespace "LIB":     cdef struct Data[int dim]:       double X[dim];       double Val[dim]; 

However, I am getting an syntax error. What is the correct syntax (if it is even possible)?

like image 786
Eldila Avatar asked Aug 27 '12 01:08

Eldila


1 Answers

Replace struct keyword to cppclass keyword. This should help.

  cdef extern from "Lib.h" namespace "LIB":       cdef cppclass Data[int dim]:         double X[dim];         double Val[dim]; 

Also check out this thread: C++ Struct inheritance in Cython

like image 164
Eldar Agalarov Avatar answered Oct 01 '22 08:10

Eldar Agalarov