Get the value of a Cython pointer

后端 未结 1 1862
执笔经年
执笔经年 2021-01-12 05:20

I am writing a function that constructs a malloc\'d unsigned char * array, and then retuns the pointer. In pure Cython or C, this is easy. All you have to do is

相关标签:
1条回答
  • 2021-01-12 05:58

    You can cast a pointer to the appropriate C type, which should then be translated into a Python integer by Cython. The correct C type is uintptr_t from <stddef.h> which in Cython would be available via from libc.stdint cimport uintptr_t. The cast is of course written <uintptr_t>array_or_pointer.

    0 讨论(0)
提交回复
热议问题