Function in file.cpp:
int runcmd(int(*func)(CMDArgs*), char *somevar) { CMDArgs* myparams = (CMDArgs *) malloc(sizeof(CMDArgs)); ZeroMemory(myparams, sizeof(CMDArgs)); HANDLE cmdthr = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)func, myparams, 0, NULL); }Prototype in file.h:
int runcmd(int(*func)(CMDArgs*), char *somevar);
When trying to compile, i get 3 errors:
2 undeclared identifiers: func and CMDArgs
1 syntax error : ')'
I can remove the undeclared identifiers by deleting them in the prototype, but I still get the syntax error. I have searched around for examples on doing this, as I wasn't sure how to pass functions as parameters before, but I haven't found anything showing why I'm having issues. All the errors pertain to that one line of code (which is line 1 of file.h). I haven't seen anything that would make me thing the issue is somewhere else. What am I missing/doing wrong? Also, why would I get the two identifier errors, when I have other function prototypes with variable names in them not causing errors. Thanks in advance for any help.