Jump to content
  • Advertisement
Sign in to follow this  
sheep19

Inline link error

This topic is 3436 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

I have this function:
Sint16 Sprite::y() const
{
     return offset.y;
}

If I change it to this:
inline Sint16 Sprite::y() const
{
     return offset.y;
}

error LNK2019: unresolved external symbol "public: short __thiscall Sprite::y(void)const " (?y@Sprite@@QBEFXZ) referenced in function _SDL_main I'm using Visual C++ 2008 EE

Share this post


Link to post
Share on other sites
Advertisement
This should work, are you sure that the cpp file in which this definition resides is visible (is it included in the project). When you get the unresolved external error that usually means that the linker cannot find the location where the function is defined ( that can happen from a mismatch of the function signature, such as when you define a function as const in declaration and not in definition or vise-versa, so you should check that the signatures are the same ) Hope this helps.

Share this post


Link to post
Share on other sites
declaration: (inside the class) in sprite.h

Sint16 Y() const;

and definition:

inside sprite.cpp

inline Sint16 Sprite::Y() const
{
return offset.y;
}

Share this post


Link to post
Share on other sites
An inline function must be defined in every translation unit in which it is used. In practice this means that it has to go inside a header file.

Share this post


Link to post
Share on other sites
Quote:
Original post by SiCrane
An inline function must be defined in every translation unit in which it is used. In practice this means that it has to go inside a header file.


That explains it, thanks.

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!