On Dec 9, 2008, at 11:27 PM, David Cournapeau wrote: > On Sun, Dec 7, 2008 at 1:46 PM, Robert Bradshaw > <[EMAIL PROTECTED]> wrote: > >> >> >> Cython doesn't actually read the .h files, so it can't figure out if >> a certain symbol is or is not defined. But if I understand your >> question correction, you want to be able to write some code with >> emits the #ifdef's? > > Yes, exactly. > >> >> One could then use it for more general macros as well. (Note that it >> still couldn't be used inside struct/enum/class definitions). > > I am not so familiar with cython, so I don't have anything to say on > which syntax is best.
A better question would be what's a "pythonic" syntax, which is the first question I ask when thinking of a new feature to add. >> As a hack, you can do >> >> cdef extern from *: >> cdef void emit_ifdef "#if defined(SOME_NAME) //" () >> cdef void emit_endif "#endif //" () >> >> emit_ifdef() >> print "hi" >> emit_endif() > > Hm, did not think about that. I guess that would do for the time > being, Yeah, it's pretty hackish, but it works. _______________________________________________ Cython-dev mailing list [email protected] http://codespeak.net/mailman/listinfo/cython-dev
