intptr_t integer type capable of holding a pointer
To cast a pointer to an int, cast it to intptr_t or uintptr_t, which are defined by C to be large enough integer types. cffi doc with examples
IntPtr is just a .NET type for void*.
The equivalent of an unmanaged pointer in the C# language is IntPtr. You can freely convert a pointer back and forth with a cast. No pointer type is
associated with it even though its name sounds like "pointer to int",
it is the equivalent of void* in C/C++.
IntPtr(5) complains that int/long' value cannot be converted to System.IntPtr. It seems like it is trying to cast or something instead of calling the constructor. (found here)
Methods of CLR objects have an '_ overloads _', which will soon be deprecated in favor of iPy compatible Overloads, attribute that can be used for this purpose. (found here)
内部没有对CFFI的直接支持Python.Net反之亦然,因此需要将指针从一个库强制转换为整数,然后将该整数重新导入到另一个库中。在
从CFFI,
intaddr = ffi.cast("intptr_t", p)
将给您一个整数。那么你可以做IntPtr(intaddr)
。在FFI内置addressof函数:
http://cffi.readthedocs.io/en/latest/ref.html#ffi-addressof
解决方法是使用
Overloads
方法IntPtr
如前所述here和{a2}。在
下面是一个工作示例:
^{pr2}$关于上面发生的事情的更多信息(可以在这里找到):
相关问题 更多 >
编程相关推荐