Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

glJunkie

inline functions problem

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

Hi everyone, When I try to make some functions inline using VC++ 6.0 - I get this error: Flock.obj : error LNK2001: unresolved external symbol "public: void __thiscall Boid::setCrashed(bool)" (?setCrashed@Boid@@QAEX_N@Z) Debug/prototype4.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. The compiler doesnt mind when I make some functions inline but some it just wont allow. Why is this? I hope someone can help. Thanks, Tim.

Share this post


Link to post
Share on other sites
Advertisement
There are issues regarding external references and inline. Read the manual, read the C++ standard, search MSDN. Keep trying.

Share this post


Link to post
Share on other sites
Yes thats correct. Check the MSDN docs, but the general idea goes something like this:

If the function is inline, it really should be short. But anyway, an inline function for a class must be written in the same header as the class, INSIDE the class declaration:

class MyClass
{
public:
inline void DoSomething(void) { return; }
};

will work,
class MyClass
{
public:
inline void DoSomething(void);
};
inline void MyClass::DoSomething(void)
{
return;
}
will not work.

-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.

Share this post


Link to post
Share on other sites
quote:
Original post by Oluseyi
The compiler, however, is free to ignore your request to inline a function.


Even with __forceinline?



Share this post


Link to post
Share on other sites
You have to link a specific library!

Go to the project configuration -> linker
and add the needed library


If the right library linked, it should compile well.

Or the linker cannot link your function, then i have no idea

Share this post


Link to post
Share on other sites
This simply just isnt true. VC++ will complain about inlining and you can force it to. In your implementation file (.cpp) make sure you use the extern keyword ex:

  

extern inline void Boid::setCrashed(bool b)
{........
}


now this will force VC++ to try to inline but its not garunteed it will, also this will cause the compiler to spit up a few warnings telling that the extern keyword is invalid for class definitions but dont worry, ive been using this in my project and it hasnt caused 1 error.

Share this post


Link to post
Share on other sites
quote:
Original post by Promit
Yes thats correct. Check the MSDN docs, but the general idea goes something like this:

If the function is inline, it really should be short. But anyway, an inline function for a class must be written in the same header as the class, INSIDE the class declaration:



Is this behaviour intended, i.e. actually part of the c++ standard? Or will it be sorted out in VC 7?

- seb

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!