Sign in to follow this  
MystikIce

external linkage to WINDOW PROCEDURE?

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 this post


Link to post
Share on other sites
Quote:
Original post by MystikIce
I 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 this post


Link to post
Share on other sites
Quote:
Original post by MystikIce
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.



// b.cpp

LRESULT CALLBACK wndProc(params here)
{
// Function definition
}

//a.cpp
extern 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.

Share this post


Link to post
Share on other sites

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

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this