# external linkage to WINDOW PROCEDURE?

This topic is 4946 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I am having an linking error. File b.cpp has my window procedure LRESULT CALLBACK wndProc(params here) { } file a.cpp has my winmain function, I defined the wndProc prototype as 'extern LRESULT CALLBACK wndProc(params here);' However I still get a linkage error. Could someone assist in explaining the proper way to link them? Thank You.

##### Share on other sites
Quote:
 Original post by MystikIceI defined the wndProc prototype as 'extern LRESULT CALLBACK wndProc(params here);

You mean you declared, function prototypes are implicitly extern so you don't need to add that. Where did you put your declartion in a header file? maybe you should post your code

##### Share on other sites
Quote:
 Original post by MystikIceHello, I am having an linking error.File b.cpp has my window procedureLRESULT CALLBACK wndProc(params here){}file a.cpp has my winmain function, I defined the wndProc prototype as 'extern LRESULT CALLBACK wndProc(params here);' However I still get a linkage error. Could someone assist in explaining the proper way to link them? Thank You.

// b.cppLRESULT CALLBACK wndProc(params here){  // Function definition}//a.cppextern LRESULT CALLBACK wndProc(params here);WinMain(){}

Just like snk_kid said, extern is for declaring, not defining. Extern is saying "The definition for this is in another file, but I'm going to use it in this file. Here's what it returns and what paramaters it takes so we can make sure the right types are being passed, and that you're asking it to return the proper type."

Think of it as a function declaration. At the top you'd have your prototype, and later in the file you'd have the definition. Well it's pretty much the same thing, except the definition is in another file and linked in EXTERNally.