Hi,
I am trying to call a function inside a class, which creates a static thread:
#include <cstdio>
#include <conio.h>
#include <SFML/System.hpp>
class MY_CLASS
{
public:
void firstFunc()
{
int counter = 0;
while(1)
{
printf("Hello from firstFunc() %d\n", counter);
counter++;
sf::sleep(sf::Time(sf::seconds(1)));
}
}
void firstFuncCaller()
{
static sf::Thread firstFuncThread(&MY_CLASS::firstFunc);
firstFuncThread.launch();
}
};
int main()
{
MY_CLASS myClassInstance;
int counter = 0;
myClassInstance.firstFuncCaller();
while(1)
{
printf("Hello from main() %d\n", counter);
counter++;
sf::sleep(sf::Time(sf::seconds(1)));
}
return 0;
}
But every time I compile it, I get the following error:
In file included from c:\mingw\include\sfml\system\thread.hpp:193:0,
from c:\mingw\include\sfml\system.hpp:40,
from srcs/consoleTests/threadTest/threadTest.cpp:3:
c:\mingw\include\sfml\system\thread.inl: In instantiation of 'void sf::priv::ThreadFunctor<T>::run() [with T = void (MY_CLASS::*)()]':
srcs/consoleTests/threadTest/threadTest.cpp:42:1: required from here
c:\mingw\include\sfml\system\thread.inl:39:25: error: must use '.*' or '->*' to call pointer-to-member function in '((sf::priv::ThreadFunctor<void (MY_CLASS::*)()>*)this)->sf::priv::ThreadFunctor<void (MY_CLASS::*)()>::m_functor (...)', e.g. '(... ->* ((sf::priv::ThreadFunctor<void (MY_CLASS::*)()>*)this)->sf::priv::ThreadFunctor<void (MY_CLASS::*)()>::m_functor) (...)'
virtual void run() {m_functor();}
^
What do I have to change in my code to let it compile properly?
Thanks for any help.