1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Function to function as pointer strange error

Discussion in 'C' started by supersoniquest, Aug 6, 2009.

  1. supersoniquest

    supersoniquest New Member

    Joined:
    Aug 6, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    hello

    i needed to make a callback function, i read a lots of articles and created this (i used this principe on simple code, and added it to my program)

    Code:
    class TKeyboard {
    public :
    ...
    void setWhilePressedCallback(void (*func) (int));
    private :
    ...
    };

    void setWhilePressedCallback(void (*func) (int)) {
    ...
    }



    but now iam getting this error after i call
    keyboard.setWhilePressedCallback(test); /*void test(int x) {}*/

    1>camera.obj : error LNK2019: unresolved external symbol "public: void __thiscall TKeyboard::setWhilePressedCallback(void (__cdecl*)(int))" (?setWhilePressedCallback@TKeyboard@@QAEXP6AXH@Z@Z ) referenced in function _main
    1>F:\Work\Visual Studio\my\camera\Debug\camera.exe : fatal error LNK1120: 1 unresolved externals


    the full source is at
    politea.sk/tmp/camera.rar

    THANK YOU FOR HELP
     
  2. supersoniquest

    supersoniquest New Member

    Joined:
    Aug 6, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    i stupid forgot to declare it as
    void TKeyboard::setWhilePressedCallback

    but had it as
    void setWhilePressedCallback


    the MVS degugger is terrible


    PROBLEM SOLVED
     
  3. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    Why is the debugger terrible? The error you got was (a) a linker error not a debugger error, and (b) exactly absolutely 100% totally correct and helpful in that it pointed you unambiguously directly at the cause of the error. How do you think the linker could be improved in that regard?
     
  4. supersoniquest

    supersoniquest New Member

    Joined:
    Aug 6, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    you dont understand whats the problem by output like this, i thought all the time it is the input parameter

    1>camera.obj : error LNK2019: unresolved external symbol "public: void __thiscall TKeyboard::setWhilePressedCallback(void (__cdecl*)(int))" (?setWhilePressedCallback@TKeyboard@@QAEXP6AXH@Z@Z ) referenced in function _main
    1>F:\Work\Visual Studio\my\camera\Debug\camera.exe : fatal error LNK1120: 1 unresolved externals


    in Borland C++ it points you nice to the line where you have an error and understandably says whats wrong.... just everybody is saying how great MVS studio is, and that i need to evolve frmo Builder To Studio...so iam working in it
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    How can Borland C++ point you to a line that doesn't exist? Unresolved External Symbol usually means you haven't written that function (it could also mean you haven't included a library in the link line), so no line number is possible.
     

Share This Page