I'm creating a c-mex s-function that calls functions from an existing library. However, due to the way that the code is set up, I need to perform an extra step when calling these functions, by creating a pointer to each function. I have one function correctly set up -- the code compiles without problems, and the generated mex file can be successfully used. However, I'm trying to duplicate this working, template setup for several other functions, and am now getting a puzzling compile error. Details are below:
My correctly functioning code is:
Code:
typedef bool (*cwPointer)(int arg1, int arg2, char *fileName);
HINSTANCE dll; /* Pointer to the .dll */
cwPointer cw; /* Pointer to "cw" function within the .dll */
dll = LoadLibrary("AC.dll");
cw = (cwPointer)GetProcAddress(dll, "cw");
cw(1, 4, "SetupFile.txt"); /* call to the function */
And here is the 2nd function that I'm attempting to declare and use in the same way:
Code:
typedef int (*gawPointer)(double *arg1, double *arg2);
gawPointer gaw; /* Pointer to "gaw" function within the .dll */
gaw = (gawPointer)GetProcAddress(dll, "gaw");
gaw(*state, *actionBuff);
Note that I excluded the "HINSTANCE dll" and "LoadLibrary" lines from the second set of code, since these only need to be included a total of once.
When this second set of code is included, I get compile failure, and the error messages include:
error C2143: syntax error : missing ';' before 'type'
--> this refers to the first line of the 2nd set of code; I notice that in the first set of code, within my code editor, "typedef" is in blue and "bool" is in black, indicating that only "typedef" is a reserved keyword. However, in the second set of code, both "typedef" *and* "int" are blue, indicating that, for some reason, the compiler is not interpreting these 2 similar "typedef" statements above equivalently.
Any suggestions about what I might need to do to resolve this error? Thanks in advance for your help!