Is it feasible for Cython to have the ability to translate C headers Cython-directives? (See here, in Conditional Compilation). A similar suggestion was made here too.
In my case, I would like these C-directives in my .h:
/* myheader.h */
#define MONIT_STEP 1 // stuff for step monit
//#define MONIT_SCATTERING 1 // monitor particle scattering
#define clight (3.0*1e10)
//#define NORM(x,y,z) (sqrt(x*x+y*y+z*z)) // maybe this is too much to ask?
to be translated to:
# cython_header.pyx
DEF MONIT_STEP = 1
DEF clight = (3.0*1e10)
So that later, I can do:
include "cython_header.pyx"
in any other .pyx
code I want to compile.
Of course, I'm implying to have the hability to ignore any character after any "//" string in the myheader.h
.
I left the NORM(x,y,z)
commented as I don't see it trivial to implement, due to its "function" nature (i.e. it's not just copy-paste).
I thought I could catch the C-preprocessor with this (see Cython docs, in "Referencing C header files"):
cdef extern from "spam.h":
pass
but doesn't work.
Of course, I can always use this method, but I'm hoping we can be more consistent.