What is the difference between these two pieces of cython code?
cdef extern from "some_header.h":
enum _some_enum:
...
ctypedef _some_enum some_enum
and:
cdef extern enum _some_enum:
...
ctypedef _some_enum some_enum
Since you have to redefine the enum
in the .pyd
file, does it matter if you say anything about the header file? Can I include it from the header file instead of retyping it?
It shouldn't be a problem to let Cython generate enum declarations. However, you typically want to use the header to ensure that the declarations are consistent. Cython will #include
the header instead of including its own declarations. That said, it doesn't actually use the declarations in the header to generate code. You still have to write compatible declarations. You can find more information in the user guide: Interfacing with External C Code: Referencing C header files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With