Thread: I want a function to run on a different thread.

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    55

    I want a function to run on a different thread.

    This is what I'm doing

    Code:
    	HANDLE handleMouse;
    	handleMouse = (HANDLE) _beginthread(threadMouse, 0, &exit);

    And this is threadMouse:

    Code:
    void threadMouse(void* args){
          ...
    }


    I'm getting this error:
    '_beginthread' : cannot convert parameter 1 from 'void (void *)' to 'void (__cdecl *)(void *)'

  2. #2
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    I believe your thread function must return a void pointer. I also think you need the WINAPI tag for Windows threads.

    Code:
    void WINAPI *threadMouse(void* args)
    I usually do pthreads, so I may be a bit off on that.
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    WINAPI is __stdcall or some other thing.

    Try:

    Code:
    void __cdecl *threadMouse(void* args)

  4. #4
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Put the * before the __cdecl, though.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Ah, yeah... Sorry about that....

    [edit] Actually, the function is supposed to return void, not a void *. It should be this I believe:

    Code:
    void __cdecl threadMouse(void* args)
    Sorry again.

    [/edit]


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. [code] Win32 Thread Object
    By Codeplug in forum Windows Programming
    Replies: 0
    Last Post: 06-03-2005, 03:55 PM
  3. Creating a thread -- Passing it a function
    By cjschw in forum C++ Programming
    Replies: 0
    Last Post: 08-05-2003, 02:46 PM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM