在Python中,从子线程传递到C API的参数没有意义

2024-06-17 15:16:59 发布

您现在位置:Python中文网/ 问答频道 /正文

假设我用Python编写了以下代码:

def subThread():
    libc.foo(56)

def mainThread():
    libc.foo(56)

    child = threading.Thread(target=subThread)
    child.start()

在C中,foo看起来像:

void foo(int a){
    printf("foo: %d\n", a);
}

通过执行python程序,我将得到以下输出

foo: 56
foo: 130810240

以前有人遇到过这种情况吗?有什么解决办法吗?你知道吗

提前谢谢。你知道吗


Tags: 代码程序childtargetfoodefthreadstart