[Pyrex] C Globals

Kent Borg kentborg at borg.org
Tue Aug 15 18:27:59 UTC 2006


How do I share a global C variable between two Pyrex functions?

I dug though the archives and found the answer, but it is too terse
for my newbie eyes to understand it.

I am trying something like:


in my .pxd file: 

    cdef extern from "foo.h":
        cdef extern int my_int

in my .pyx file:

    def my_func():
        cdef int my_int

        my_int = 42

    def my_other_func():
        cdef extern int my_int

	some_useful_func(my_int)

And I have tried variations that also don't work.  Can someone correct
my work here?


Thanks,

-kb



More information about the Pyrex mailing list