Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Function to function as pointer strange error (http://www.go4expert.com/forums/function-function-pointer-strange-error-t18848/)

supersoniquest 6Aug2009 19:04

Function to function as pointer strange error
 
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

supersoniquest 6Aug2009 20:03

Re: Function to function as pointer strange error
 
i stupid forgot to declare it as
void TKeyboard::setWhilePressedCallback

but had it as
void setWhilePressedCallback


the MVS degugger is terrible


PROBLEM SOLVED

xpi0t0s 9Aug2009 00:58

Re: Function to function as pointer strange error
 
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?

supersoniquest 9Aug2009 14:14

Re: Function to function as pointer strange error
 
Quote:

Originally Posted by xpi0t0s (Post 54613)
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?

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

xpi0t0s 9Aug2009 15:18

Re: Function to function as pointer strange error
 
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.


All times are GMT +5.5. The time now is 03:25.