void pointer to void array

In my code you can see I am sending a void pointer of a void pointer array to my thread function.. This is the only way i could think of to do this, however is seems.. wrong.. Its messy, and doesn't seem like something that should ever have to be done..

http://levone.pastebin.com/LhDLB9Y2
http://pastebin.com/a12KKcF7

Is there a better or correct way to do this?
Last edited on
Nearly all threading interfaces are used this way, or some variation thereof. Get used to it:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
struct thread_params{
    int foo;
    std::string bar;
};

void thread(void *p){
    thread_params *params=(thread_params *)p;
    //...
}

//...
thread_params tp;
//Hypothetical function that creates a new thread.
//void new_thread(void(*)(void *),void *);
new_thread(thread,&tp);
oh I see..
Well, using a struct(class in my case) like that is a good idea.. dunno why i don't think of it.. xD

Will at least not be so messy. Thanks helios.
You'll want to use Boost.Thread - there's going to be none of this void* mess.
I do use Boost for programs that are only for Computers.
I use SDL for games that run on a bunch of different devices since SDL has been ported to every system I code for.
Topic archived. No new replies allowed.