Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a macro to expand in Cython

Tags:

cython

I have a C header which defines a function in a macro. I need to call it from Cython. Is there a way to use the macro in Cython and have it fully expanded? I already have the arguments as C types.

I've tried using cdef like I would for a function, which is, I think, what the documentation says.

like image 669
Peter Graham Avatar asked Apr 30 '14 06:04

Peter Graham


1 Answers

Do you mean something like this?

#define SUM(a,b) (a) + (b)

In this case, declare it as a function in a cdef extern from "lib.h" block, and specify the type of arguments it takes and should return. Refer to the docs.

like image 58
gg349 Avatar answered Dec 17 '22 14:12

gg349