Jump to content
  • Advertisement
Sign in to follow this  
MystikIce

external linkage to WINDOW PROCEDURE?

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

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!