Possible Duplicate:
pthread Function from a Class이는 pthread_create
를 사용할 때 오류가 나는 C 상당히 새로운 오전 ++ 나는 TCP에 대한 프로젝트를하고있는 중이 야.
내가 인터넷 검색을 할 수 있도록 스레드를 만들어야합니다. http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html
내가 오류의 구문을 따라야하지만, 발생 : 유형의 인수 '무효 *을 (NS3는 :: TcpSocketBase는 :)()'
'무효 * () (무효를)'과 일치하지 않습니다 코드 :
tcp-socket-base.h:
class TcpSocketBase : public TcpSocket
{
public:
...
void *threadfunction();
....
}
tcp-socket-base.cc:
void
*TcpSocketBase::threadfunction()
{
//do something
}
..//the thread was create and the function is called here
pthread_t t1;
int temp = pthread_create(&t1, NULL, ReceivedSpecialAck, NULL); //The error happens here
return;
...
어떤 도움을 주시면 감사하겠습니다. 감사!
편집 :
은 내가 조언을 가져다가이 쓰레드에게 비 멤버 함수를합니다.
namespaceXXX{
void *threadfunction()
int result = pthread_create(&t1, NULL, threadfunction, NULL);
NS_LOG_LOGIC ("TcpSocketBase " << this << " Create Thread returned result: " << result);
void *threadfunction()
{
.....
}
}
하지만 대신이 오류 가지고 :
의 인수 3 초기화 '의 INT는 pthread_create (가 pthread_t의 *, const를 pthread_attr_t의 *를 무효 * () (무효), 무효 *)'[-fpermissive ]
또한 boost :: thread를 사용하는 것이 좋습니다. 그러면 인생이 훨씬 쉬워 질 것입니다. – fluffy