Thread problem; function call missing argument list

Hi

I’m using threads for the first time, and I have a class (singleton) where I am setting up a thread:

SDL_Thread *myThread = NULL; // global

MyClass::MyClass(void) // constructor
{
myThread= SDL_CreateThread(myThreadFunction,NULL);
}

int MyClass::myThreadFunction(void *data)
{
return 0;
}

When I compile, I keep getting:

error C3867: ‘MyClass::myThreadFunction’: function call missing argument list; use ‘&MyClass::myThreadFunction’ to create a pointer to member

But this shouldn’t be occuring…what’s going on?! It looks so simple in the examples…

Thanks in advance!
Ed___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/

Edward Byard escreveu:

MyClass::MyClass(void) // constructor
{
myThread= SDL_CreateThread(myThreadFunction,NULL);
}

int MyClass::myThreadFunction(void *data)
{
return 0;
}

SDL_CreateThread takes a pointer to a function. So myThreadFunction
needs to be a “class function” (aka static method) or plain function.
You didn’t post the class declaration, but if I were to guess,
myThreadFunction was declared as a plain method, not as a static method.—
Daniel K. O.

Thanks - you were right - couldn’t see the wood for trees :-)> ----- Original Message -----

From: danielko.listas@gmail.com (Daniel K. O.)
To: A list for developers using the SDL library. (includes SDL-announce)
Sent: Sunday, 15 April, 2007 10:32:43 PM
Subject: Re: [SDL] Thread problem; function call missing argument list

Edward Byard escreveu:

MyClass::MyClass(void) // constructor
{
myThread= SDL_CreateThread(myThreadFunction,NULL);
}

int MyClass::myThreadFunction(void *data)
{
return 0;
}

SDL_CreateThread takes a pointer to a function. So myThreadFunction
needs to be a “class function” (aka static method) or plain function.
You didn’t post the class declaration, but if I were to guess,
myThreadFunction was declared as a plain method, not as a static method.


Daniel K. O.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  ___________________________________________________________ 

Yahoo! Mail is the world’s favourite email. Don’t settle for less, sign up for
your free account today http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html

I’m using threads for the first time, and I have a class (singleton) where
I am setting up a thread:

I’d suggest not mixing several things, remove the class and the singleton to
narrow the fault to the most simple example.

SDL_Thread *myThread = NULL; // global

Why global?

MyClass::MyClass(void) // constructor
{
myThread= SDL_CreateThread(myThreadFunction,NULL);
}

FYI: the void in the argument list is optional in C++.

int MyClass::myThreadFunction(void *data)
{
return 0;
}

When I compile, I keep getting:

error C3867: ‘MyClass::myThreadFunction’: function call missing argument
list; use ‘&MyClass::myThreadFunction’ to create a pointer to member

Read the C++ FAQ at parashift’s. It explains the difference between a function
and a memberfunction and also how to combine those two.

UliOn Sunday 15 April 2007 21:43, Edward Byard wrote: