Sign in to follow this  
sheep19

Inline link error

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

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