Is it possible to "wrap" a function pointer in C somehow, similar to what you would do with a lambda in C#?
Actual problem I am having is:
I have a couple of functions with different parameters:
// more than two in actual code
void DoStuff(void) { ... }
void DoOtherStuff(int) { ... }
...and I want to create a couple of threads to run these in a loop:
// this won't work because it expects a LPTHREAD_START_ROUTINE,
// which is int(*fn)(void*)
tHnd1 = CreateThread(NULL, 0, &DoStuff, NULL, 0, &tId);
tHnd2 = CreateThread(NULL, 0, &DoOtherStuff, NULL, 0, &tId);
In C#/C++ I would use a lambda, or a pointer to a method which would call the other one, but I have no clue how to do this in C, unless I manually create wrapper functions:
int CallDoStuff(void *dummy) { DoStuff(); return 0; }
int CallDoOtherStuff(void *dummy) { DoOtherStuff(42); return 0; }
Is there any other way to avoid doing this step?