[Pyrex] [Cython] Pyrex and const (Re: constify Cython output all over the place (newbie approach))
Ravi Lanka
ravi_lanka at acusim.com
Thu May 15 15:08:37 CEST 2008
Greg Ewing wrote:
> Kirill Smelkov wrote:
>
>
>> I think this is going to be trouble at least when interfacing with external
>> C++ code and libraries - at least at link time.
>>
>
> You're right, it would break C++ interfacing in a big
> way.
>
> So I guess I'll just have to bite the bullet and provide
> proper const support. A pity, because it would have been
> nice to spare Pyrex users from the tyranny of constness.
>
>
I have been using pyrex to interface C as well as C++ code. I use the
following trick to handle const ( mostly because of the cpp code),
foo.h
void foo( const int* p) { ... }
mydefines.h
#define ConstInt const int
foo.pyx
cdef extern from "mydefines.h":
ctypedef int ConstInt
cdef extern from "foo.h":
void foo(ConstInt * p)
Without the above trick, I had to manually edit the cpp file that got
generated by pyrex.
hope this helps,
Ravi
More information about the Pyrex
mailing list