小编Nau*_*lus的帖子

C与C++中Pthread之间的差异

所以我能够使用Ada_function'Address将Ada函数传递给C_function.这是C函数:

void Create_Process(int * status, void * function) {
    pthread_t new_thread;

    //creating function with the given function and no arguments.
    *status = pthread_create(&new_thread, NULL, function, NULL);
}
Run Code Online (Sandbox Code Playgroud)

这非常好.我的问题是当我尝试在C++中使用相同的功能时.它无法编译错误:

error: invalid conversion from ‘void*’ to ‘void* (*)(void*)’ [-fpermissive]
*status = pthread_create(&new_thread, NULL, function, NULL);
Run Code Online (Sandbox Code Playgroud)

有没有什么理由可以在C中运行/编译而不是C++?

c c++ posix pthreads ada

1
推荐指数
1
解决办法
914
查看次数

标签 统计

ada ×1

c ×1

c++ ×1

posix ×1

pthreads ×1