972
edits
[unchecked revision] | [unchecked revision] |
m (add another option) |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
Line 7:
'''File: example1.h'''
<
inline long something(long i)
{
return i + 2;
}
</syntaxhighlight>
'''File: example1.c'''
<
#include "example1.h"
extern inline long something(long i);
</syntaxhighlight>
This way, the compiler inlines the function if possible, but additionally allocates a name or reference that points to the specific implementation, in case a call is needed when inlining is not possible.
Line 25:
'''File: example2.h'''
<
static inline long something(long i)
{
return i + 2;
}
</syntaxhighlight>
This is another solution, adding the static keyword.
|