Thread: Syntax question about c-mex s-functions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2010
    Posts
    67

    Syntax question about c-mex s-functions

    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!
    Last edited by CodeKate; 08-30-2011 at 11:26 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Syntax for functions
    By Mentallic in forum C Programming
    Replies: 2
    Last Post: 08-27-2011, 12:11 AM
  2. Syntax for Declaring Functions in Dev-C++
    By Muz in forum C Programming
    Replies: 4
    Last Post: 07-03-2007, 04:53 AM
  3. Syntax Help, class interactions and functions..
    By Shamino in forum C++ Programming
    Replies: 18
    Last Post: 05-17-2007, 01:09 PM
  4. Replies: 3
    Last Post: 10-31-2006, 02:15 AM
  5. Geometry-shapes functions' syntax ?
    By bigjoke in forum C Programming
    Replies: 9
    Last Post: 01-01-2006, 10:25 PM