Function Pointer Problem (In An Abstraction Class)

So long story short I'm creating yet another abstraction class for threading that's multi-platform. I'm creating the class to abstract away from the pthread of linux and windows threading and also create a convenient class for my program to use. Suffice to say I've run into a bit of a snag.

Here's a bit of HPP code I've whipped up to encapsulate the scenario:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#ifdef _WIN32
	#define WIN32_LEAN_AND_MEAN
	#include <windows.h> //Mutex's, Threads, Dynamic Library Loading
#else
#endif
#ifdef _WIN32
	typedef DWORD ThreadId;
	typedef HANDLE ThreadHandle;
#else
#endif
struct ThreadArgs {
	bool* quitting,			//Whether the thread has been requested to terminate operation
		*exited;			//Whether the thread has exited
	void* arguments;		//The function arguments
	bool (*func)(void*);	//The function address
};
class Thread {
private:
	//Data
	bool quitting,	//Whether the thread has been requested to terminate operation
		exited;		//Whether the thread has exited
	ThreadArgs tArgs;
	ThreadHandle handle;
	ThreadId id;
	//Functions.Internal
	#ifdef _WIN32
		static DWORD WINAPI ThreadRuntime(void* arguments) {
			ThreadArgs* args = (ThreadArgs*)arguments;
			bool success = true;
			do {
				success = (*args->func())(args->arguments);
				if (success && !(*args->quitting))
					time_::sleep(THREAD_SLEEP);
			} while (!(*args->quitting) && success);
			*args->exited = true;
			return ((success)?0:1);
		}
	#else
	#endif
public:
	//Functions.External.Construction
	Thread();
	Thread(bool (*func)(void* args), void* args, bool runOnce = false);
	~Thread();
	//Functions.External.Operation
	bool start(bool (*func)(void* args), void* args, bool runOnce = false);	//Starts the thread runtime cycle
	bool stop(bool threadJoin = false, bool forcefully = false);			//Stops the thread runtime cycle
	void join();															//Joins the thread with the calling thread (Blocks the caller thread until this class' thread has terminated)
	//Todo: setStartupPriority
	ThreadId getThreadId();
	ThreadHandle getThreadHandle();
};

error C2198: 'bool (__cdecl *)(void *)' : too few arguments for call

-> success = (*args->func())(args->arguments);

So as you can see, it claims my call to the passed function has too few arguments, when it only required one (A void pointer) and that's exactly what I give it. A search of both google and this forum yielded no results worth noting, hopefully I didn't miss any and waste your time. One possible cause I could think of was it interpreted the void* to actually be void, and expects 0 arguments, but the console says not ENOUGH so I don't know... Any help would be greatly appreciated!
Last edited on
Wow I found the problem, did *args->func() instead of *args->func.
A simple mistake, unfortunately it took me most of the day to find it, and conveniently right after I posted this...
Topic archived. No new replies allowed.