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 ) { /* Shut the timer down, make sure interrupts are all off */ UTL_TIMER_TCCRA = 0; UTL_TIMER_TCCRB = 0; UTL_TIMER_TIMSK = 0; /* Set the wait into the counter - this value must be pre-computed * using the WAIT_TIMER_US_TO_TCNT macro! */ UTL_TIMER_TCNT = Wait; /* set up the utility timer: * Source clock: System clock / 1 * Mode: Normal * Output: none * Interrupt: on nothing */ UTL_TIMER_TCCRA = 0; UTL_TIMER_TCCRB = ( UTL_TIMER_CS0 ); /* Clear the overflow flag */ UTL_TIMER_TIFR = UTL_TIMER_TOVF; } And is used as: static bool FcsAcquireLookForSumOKDeassert( void ) __attribute__((always_inline)); static bool FcsAcquireLookForSumOKDeassert( void ) { /* Wait for SumOK to deassert */ while ( ( FCS_SUMOK_PIN & FCS_SUMOK_H ) && ! g_DacRampCompleteFlag ) { /* Delay for 1uS (use _delay_loop_1 so optimization does not affect this) */ _delay_loop_1( FCS_GENERIC_1uS_LOOP_WAIT ); } /* Set up debounce */ FcsStartUtilTimer( WAIT_TIMER_US_TO_TCNT( FCS_SIGNAL_DEASSERT_DEBOUNCE ) ); /* Debounce SumOK */ while ( ! ( UTL_TIMER_TIFR & UTL_TIMER_TOVF ) && ! g_DacRampCompleteFlag ) { if ( FCS_SUMOK_PIN & FCS_SUMOK_H ) { /* HMMMMmmm.. Went high - reset the counter */ FcsResetUtilTimer( WAIT_TIMER_US_TO_TCNT( FCS_SIGNAL_DEASSERT_DEBOUNCE ) ); } } return (! g_DacRampCompleteFlag); } 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 ... 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