å¨å°è£
ç代ç é´ä¼ éæéä½ è¦ç¡®ä¿ä»ä»¬è¿è¡å¨ç¸åçå°å空é´éï¼è¿è¦ä¿è¯æéæåçå
åççåææ¯å®å
¨çï¼å¦åè¿ç§æ路就æ¯é误çãå®ç°æ¹æ³ä¸¾ä¾å¦ä¸ï¼
1ãå®ä¹äºC ç»æä½åå½æ°å¦ä¸
typedef struct NameAge
{
char name[20];
int age;
}NameAge , *NameAgePointer;
void test(NameAgePointer p) // æ¥æ¶ç»æä½æé
{
// do something with p...
}
2ãpythonå®ä¹ç»æä½å¦ä¸
#pythonä¸ç»æä½å®ä¹
class PyStruct():
def __init__(self, name, age):
self.name = name
self.age = age
fred = PyStruct("fred", 5)
3ãå设æ第1æ¥éçtestå°è£
æexample模åï¼python导å
¥exampleï¼æ¢ç¶ä½ é½ä¼swigäºï¼è¿ä¸ªè¿ç¨å°±ä¸å°å¦äºï¼
>>>import example
>>>example.test(pointer(fred))
以ä¸æ¯åºæ¬æè·¯ï¼å 为æ建å¼åç¯å¢åè¿ç¨æ¯è¾ç¹æï¼æ²¡æéªè¯è¿ï¼ä½æ¯åºè¯¥æ²¡æ大é®é¢
温馨提示:内容为网友见解,仅供参考