1
我有一個包含原始字段(int,uint8,...)和指針的結構。 這些指針通常指向一個不同結構類型的數組,以保持深度嵌套結構。 例如,在C:python ctypes:從指針變量中獲取指針類型
struct A
{
int field1;
int field2;
struct B *fields3;
unsigned int countofb;
}
struct B
{
int anotherfield1;
int anotherfield2;
}
在蟒與ctypes的創建的結構的一個包裝和B. 迭代以上結構A的_fields_
我到達第三字段field3
和我得到LP_struct_B
類型的CTYPE變量。
問題是,有沒有一種方法,一個函數,ctypes的方法將指針轉換爲指向類型?
我需要這樣的東西
a=A()
st=pointedtype(a.field3) # or also st = pointedtype2(LP_struct_B)
#desired output: st = struct_B
感謝