Keep in mind that inline
is just a hint, a request if you will. The compiler is well within it's bounds to ignore your request if it sees fit.
It might do this because of optimization settings, or other reasons.
You might ask yourself if you really need these functions to be inline
. This is a common premature micro-optimization, perpetuated by some texts advising that small & frequently-called functions could be inlined to improve performance. Unless there's a performance problem, your just adding complexity by inlining these functions.
If you move the implementation of the functions to a CPP file, inline
directive intact, you may have better luck. The compiler may ignore your inline
request as it seems to be doing now, but you should compile just fine. You might also be able to make your functions template functions, thereby asking the compiler to inline
them again, which again it may ignore.
EDIT: From the comments below, I think it's a good idea to clarify what "inline
is just a hint" means.
From the Standard:
7.1.2 Function Specifiers
2: A function declaration (8.3.5, 9.3,
11.4) with an inline specifier declares an inline function. The
inline specifier indicates to the
implementation that inline
substitution of the function body at
the point of call is to be preferred
to the usual function call mechanism.
An implementation is not required to
perform this inline substitution at
the point of call; however, even if
this inline substitution is omitted,
the other rules for inline functions
defined by 7.1.2 shall still be
respected.
So, when you put the declaration and the definition of a function in a header file with the inline
keyword, like this:
namespace myNamespace {
inline bool myFunction() {return true;}
}
...there are a couple of spinning plates. First, in order for the program to be well-formed, the inline
keyword needs to be respected by the compiler, otherwise you will violate the one-definition rule. But second, there is still no requirement by the implementation to honor your inline
request. If it does, you're golden. If it doesn't, you're screwed. In effect, the well-formedness of your program depends on the compiler respecting your inline
request.
I have re-read the Standard with respect to inline
and found nothing that indicates that a compiler must respect inline
for certain cases. If anybody knows of a clause that makes my claim incorrect, please share it!