# Thread problem; function call missing argument list

**URL:** <https://discourse.libsdl.org/t/thread-problem-function-call-missing-argument-list/14469>\
**Category:** SDL Development\
**Created:** [April 15, 2007, 7:43pm UTC](https://discourse.libsdl.org/t/thread-problem-function-call-missing-argument-list/14469 "2007-04-15T19:43:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Edward\_Byard](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/9e8a1a/32.png) [@Edward\_Byard](https://discourse.libsdl.org/u/Edward_Byard)\
**Post date:** [April 15, 2007, 7:43pm UTC](https://discourse.libsdl.org/t/thread-problem-function-call-missing-argument-list/14469/1 "2007-04-15T19:43:38Z")

</div>

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/](http://uk.answers.yahoo.com/)

---

<div class="post-metadata">

**Author:** ![Daniel\_K\_O](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/d/a4c791/32.png) [@Daniel\_K\_O](https://discourse.libsdl.org/u/Daniel_K_O)\
**Post date:** [April 15, 2007, 9:32pm UTC](https://discourse.libsdl.org/t/thread-problem-function-call-missing-argument-list/14469/2 "2007-04-15T21:32:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Edward\_Byard](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/e/9e8a1a/32.png) [@Edward\_Byard](https://discourse.libsdl.org/u/Edward_Byard)\
**Post date:** [April 15, 2007, 10:02pm UTC](https://discourse.libsdl.org/t/thread-problem-function-call-missing-argument-list/14469/3 "2007-04-15T22:02:01Z")

</div>

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

> From: [danielko.listas@gmail.com](mailto: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)  
> [http://lists.libsdl.org/listinfo.cgi/sdl-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](http://uk.rd.yahoo.com/evt=44106/*http://uk.docs.yahoo.com/mail/winter07.html)

---

<div class="post-metadata">

**Author:** ![Ulrich\_Eckhardt](https://discourse.libsdl.org/letter_avatar_proxy/v4/letter/u/e480ec/32.png) [@Ulrich\_Eckhardt](https://discourse.libsdl.org/u/Ulrich_Eckhardt)\
**Post date:** [April 15, 2007, 10:25pm UTC](https://discourse.libsdl.org/t/thread-problem-function-call-missing-argument-list/14469/4 "2007-04-15T22:25:02Z")

</div>

> 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:
