小编gre*_*reg的帖子

无法将 'std::function<void*()>' 转换为 'void* (*)(void*)'

我是使用<functional>图书馆的新手,所以请耐心等待。以下代码无法编译,并出现此错误:

错误:无法转换std::function<void*()>void* (*)(void*)的论点3int pthread_create(pthread_t*, const pthread_attr_t*, void* (*)(void*), void*)

我不必<functional>在我的代码中使用,但我想在放弃和使用标准函数指针之前,我会看看是否有解决方案。

这是我所拥有的:

vector< function< void*() > > signals;
vector< pthread_t > signal_threads;

// Master Signal Handler
void MasterSignalHandler()
{
    for (auto & signal_handler : signals)
    {
        // Create a thread handle
        pthread_t thread_handle;

        // Spawn a thread for the signal handler
        if (0 == pthread_create(&thread_handle, NULL, signal_handler, NULL))
        {
                // Push back the thread handle to the signal thread …
Run Code Online (Sandbox Code Playgroud)

c++ pthreads

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

标签 统计

c++ ×1

pthreads ×1