Stu Bell wrote:
David Brown wrote:
And an __attribute_((always_inline)) function will be
inlined, regardless of the optimisation levels.
Sorry, compiler breath -- this is not always true. If you call an
"always_inline" function from inside another "always_inline" function,
with optimization turned off, the compiler throws a fit.
Example -- WinAVR 20090313, file compiled with -O0. Inline function is:
static void
FcsStartUtilTimer( uint16_t Wait ) __attribute__((always_inline));
static void
FcsStartUtilTimer( uint16_t Wait )
{
<snip>
Returns the following error:
CmdFocus.c: In function 'FcsAcquireLookForSumOKDeassert':
CmdFocus.c:4020: sorry, unimplemented: inlining failed in call to
'FcsStartUtilTimer': function body not available
CmdFocus.c:4152: sorry, unimplemented: called from here
...
That's hardly "throwing a fit" - it's simply telling you it can't obey
the "always_inline" attribute.
However, I think the problem stems from a misunderstanding about
"always_inline" - it's an /additional/ request to the compiler that you
can use for /inline/ functions. From the gcc documentation:
always_inline
Generally, functions are not inlined unless optimization is
specified. For functions declared inline, this attribute inlines the
function even if no optimization level was specified.
If you declare your functions "inline", it should work as you desire
even with -O0:
static inline void
FcsStartUtilTimer( uint16_t Wait ) __attribute__((always_inline));
static inline void
FcsStartUtilTimer( uint16_t Wait )
mvh.,
David
The above code compiles fine if the optimizer is turned on (-Os). Of
course, I guess the real question (which I have not investigated) is
whether it compiles *correctly* with -Os. :-/ It functions correctly,
so I presume it is inlining correctly.
Best regards,
Stu Bell
DataPlay (DPHI, Inc.)
_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list