25

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

Eldila
  • 15,426
  • 23
  • 58
  • 62

1 Answers1

3

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

Community
  • 1
  • 1
Eldar Agalarov
  • 4,849
  • 4
  • 30
  • 38