2012-06-03 91 views
2

你好,我需要一个正确产卵线程的手,我似乎无法得到正确的语法。 这里是我的代码...C++产生线程

// Spawn a thread--------------------------------------------------#  
    pthread_t thread1; // thread object 
    int rc1; 

    if((rc1=pthread_create(&thread1, NULL, spellCheck, NULL))) 
    { 
     cout << "Thread creation failed: " << rc1 << endl; 
    } 

    pthread_join(thread1, NULL); 

函数定义

void spellCheck(vector<string> * fileRead, list<string> * incorrectWord, vector<string> * correctWord) 
{ 

头文件

void spellCheck(vector<string> *fileRead, list<string> *incorrectWord, vector<string> *correctWord); 

任何帮助,将不胜感激:)

我的错误:

server.cpp:142: error: invalid conversion from 'void()(std::vector<std:................. initializing argument 3 of 'int pthread_create(pthread_t, const pthread_attr_t*, void*()(void), void*)' 
+1

你什么错误? – SLaks

+0

server.cpp:142:错误:无效转换从'void(*)(std :: vector

回答

5

我可能是错在这里,但我还以为你实现和线程函数传递给在pthread_create()只能有一个(void *的)输入参数

+0

ohk我明白你得到什么 –

+0

试试这个 - http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html – mathematician1975