What's new

I want to learn some programming

Doomulation

?????????????????????????
Interesting... I'll have a look at this. Note that it accepts a void* arguments, which means that you can't have a function declaration which accepts an argument with anything else than void*.

UPDATE:
After studying it a little, I think I grasp what you're doing.
You're basically using a dummy class to define a pointer to a class in the thread structure... you're basically using unions (can't say I know much about them) so that data will duplicated into different types of pointers. That way, you could have a class function pointer and a global function pointer with the same address. That way, all you need is check if we're doing a class callback or not, then access the appropriate struct members...
Of course, when calling the new thread procedure, you simply cast the class function to the class function pointer for your dummy class...

I never would have thought that way. It shows that it works if you think hard enough.
But I can't say that it's much better than assembly, because this is pretty much stretching the language to its limits. It's in no way a standard procedure and is very dangerous.
 
Last edited:

civilian0746

evil god
void* is but another pointer. You can cast it to any other pointer types. Excuse some extra codes that might be in there. In the begining I tried to do everything with classes.
 

Doomulation

?????????????????????????
I know it is, but if the thread creator procedure takes a void* pointer, then it doesn't know what type it was from the beginning and thus the callback MUST take a void* as argument. IF you used a template argument instead, it could pass it right on and you don't need to cast your arguments back and forth.
 

civilian0746

evil god
Well, it does not need to. Its a secret between the person who calls the thread creation function and the thread callback function/method ^_^. It would not make much of a difference if you supplied a number as void*. Personally, I dont like fat function calls.
 
Last edited:

Top