Essayait d'utiliser une classe de threads que j'avais créée sous Windows, sous Linux. Netbeans pour elle a choisi, et dans les paramètres du projet que j'ai spécifié Linker > Additional Library Directories
comme /usr/local/boost_1_53_0
Sous Libraries
, je spécifié boost_thread-mt
Sous C++ Compiler > Include Directories
I spécifié /usr/local/boost_1_53_0
boost :: _ bi :: unwrapper <F> :: unwrap ne peut pas être utilisé en tant que fonction?
thread.h
et Thread.cpp
sont mes fichiers. Thread.hpp
appartient à Boost.
L'erreur est montré à la ligne où j'ai inclus #include <boost/thread/thread.hpp>
et l'erreur est:
/usr/local/boost_1_53_0/boost/bind/bind.hpp: In member function ‘void
boost::_bi::list1<A1>::operator()(boost::_bi::type<void>, F&, A&, int)
[with F = unsigned int (**)(void*), A = boost::_bi::list0, A1 =
boost::_bi::value<void*>]’: In file included from
/usr/local/boost_1_53_0/boost/bind.hpp:22:0,
from /usr/local/boost_1_53_0/boost/thread/detail/thread.hpp:29,
from /usr/local/boost_1_53_0/boost/thread/thread.hpp:22,
from ../../../TSDK-master/src/Core/source/thread.h:72,
from ../../../TSDK-master/src/Core/source/Thread.cpp:95:
/usr/local/boost_1_53_0/boost/bind/bind_template.hpp:20:59:
instantiated from ‘boost::_bi::bind_t<R, F, L>::result_type
boost::_bi::bind_t<R, F, L>::operator()() [with R = void, F = unsigned
int (**)(void*), L = boost::_bi::list1<boost::_bi::value<void*> >,
boost::_bi::bind_t<R, F, L>::result_type = void]’
/usr/local/boost_1_53_0/boost/thread/detail/thread.hpp:117:17:
instantiated from ‘void boost::detail::thread_data<F>::run() [with F =
boost::_bi::bind_t<void, unsigned int (**)(void*),
boost::_bi::list1<boost::_bi::value<void*> > >]’
../../../TSDK-master/src/Core/source/Thread.cpp:202:50: instantiated
from here /usr/local/boost_1_53_0/boost/bind/bind.hpp:253:9: error:
‘boost::_bi::unwrapper<F>::unwrap [with F = unsigned int
(**)(void*)]((* & f), 0l)’ cannot be used as a function
Am complètement désemparés quant à ce qui en est la cause. Quelqu'un pourrait-il aider?
EDIT:
une partie de thread.h
#include <boost/thread/thread.hpp>
#include <cstdio>
class Thread
{
protected:
boost::thread* m_Thread;
unsigned int id;
private:
bool m_pause;
boost::mutex m_pause_mutex;
boost::condition_variable m_pause_changed;
bool threadCreated;
public:
Thread();
Thread(unsigned int id);
~Thread();
bool Start();
bool CreateThread(unsigned int Function(void* pParam),void *pParam);
void Terminate();
unsigned int myThreadProc(void* param);
bool IsRunning();
bool IsStarted();
protected:
virtual unsigned int ThreadProc() = 0;
};
et une partie de thread.cpp
#include "thread.h"
Thread::Thread() : m_Thread(NULL), m_pause(true), threadCreated(false), id(NULL)
{
}//Thread ctor
Thread::Thread(unsigned int _id) : m_Thread(NULL), id(_id), threadCreated(false), m_pause(true)
{}
Thread::~Thread()
{
if (NULL != m_Thread) { delete m_Thread; }
}
unsigned int Thread::GetThreadID() { return id; }//GetThreadID
bool Thread::Start()
{
m_Thread = new boost::thread(&Thread::myThreadProc, this, this);
threadCreated = true;
return threadCreated;
}
bool Thread::CreateThread(unsigned int Function(void* pFunctionParam),void *pParam)
{
//Receives Thread Function,pParam as Arguments and starts Thread.
m_Thread= new boost::thread(&Function,pParam);
threadCreated = true;
return threadCreated;
}
void Thread::Terminate()
{
if (NULL != m_Thread) {
m_Thread->join();
m_Thread=0;
}
else {printf("No thread was created\n");}
}
unsigned int Thread::myThreadProc(void* param)
{
Thread* ourBoostThread = (Thread*) param;
int ret = ourBoostThread->ThreadProc();
return ret;
}//_ThreadProc
bool Thread::IsRunning() { return !m_pause; }
bool Thread::IsStarted() { return threadCreated; }
Ligne 202 est bool Thread::IsStarted() { return threadCreated; }
Veuillez publier le code qui génère cette erreur. – Praetorian
Sur la ligne 202 de "Core/source/Thread.cpp", vous essayez d'appeler 'boost :: bind' (ou peut-être une fonction de thread qui à son tour appelle cela) incorrectement. Pourriez-vous nous montrer cette ligne, et les déclarations de tout ce que vous essayez de lier? –
En fait, maintenant j'ai reformaté le message d'erreur afin que nous puissions tout lire, cela ressemble beaucoup à l'utilisation d'un pointeur sur un pointeur de fonction où vous devriez simplement utiliser un pointeur de fonction. Mais je ne peux pas être entièrement sûr sans voir votre code. –