|
RE: [gbadev] Argh, VC++ inlines.
Hey Thomas,
If you put inline before a function, that function has to exist in the
header file.
Otherwise, you'll get unresolved external symbols.
There is a tradeoff of being able to step through inline functions and
speed.
A solution to this is to make your own INLINE macro,
that in #ifdef _DEBUG evaluates to nothing and otherwise evaluates to
inline.
You then place the inline functions in a separate file, call it foo.inl for
example.
Then the h file looks like:
#ifndef _DEBUG
#include "foo.inl"
#endif // !_DEBUG
In the .cpp file, it looks like:
#ifdef _DEBUG
#include "foo.inl
#endif // _DEBUG
This means, when I'm in debug...
I don't want to treat these functions as truly inline.
Instead, include them in the implementation file.
In release, it means...
Treat these inline functions, I'm looking for max speed.
While inline functions are a good thing in general (especially for simple
accessor manipulator code), you should a profiler on your code.
This way you have real data to figure out what is taking the most time.
- Jeff
|