Thread: why typedef? and not a pointer to function?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    113

    why typedef? and not a pointer to function?

    hi,
    i'm tryinfg to load a function from a dll, this dll haves a function
    Code:
    void mensaje();
    in my client program when i try to load the function why i cant use or define a pointer to that function when retrieving from GetProcAddress()?

    ok a little bit more clear:
    Code:
    //pointer to the function to retrieve
    void(* ptrFunc)(void) = NULL;
    ...
    ptrFunc = GetProcAddress(dllLib,"mensaje");
    //here compiler generates an error
    but if i use typedef everything is fine

    Code:
    ...
    typedef void(WINAPI*ptrFunc)();
    ...
    ptrFunc funcion1;
    funcion1 = (ptrFunc)GetProcAddress(dllLib,"mensaje");
    so why cant use a pointer to the function to handle with the GetProcAdress() return value?
    GetProcAdress() returns a pointer to the specified function no?

    one more question:
    what
    Code:
    typedef void(WINAPI*ptrFunc)();
    means?
    im aliassing a pointer to a WINAPI function that returns no value and gets no value? is that what it means?

    thanks for any help why i need to define a typedef

    please excuse my poor english
    Last edited by terracota; 12-17-2004 at 10:01 AM.

Popular pages Recent additions subscribe to a feed