# external linkage to WINDOW PROCEDURE?

## Recommended Posts

MystikIce    122
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
snk_kid    1312
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
DesCr    100
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.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account