[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] inline vs. #define
From: |
E. Weddington |
Subject: |
Re: [avr-gcc-list] inline vs. #define |
Date: |
Tue, 25 Mar 2003 14:56:41 -0700 |
On 25 Mar 2003 at 13:23, Andreas Trenkwalder wrote:
> Hi,
>
> How are inline functions handled by avr-gcc?
>
> if i use
> #define i2c_wait() while (!(TWCR & _BV(TWINT)))
>
> avr-size says:
> text data bss dec hex filename
> 388 0 1 389 185 i2c.elf
>
>
> instead if i use
> inline void i2c_wait(void)
> {
> while (!(TWCR & _BV(TWINT)));
> }
>
> avr-size output looks like
> text data bss dec hex filename
> 398 0 1 399 18f i2c.elf
>
> Why is there a difference in size?
Take a look at the mixed C and assembly listing. You'll see that
functions incur an overhead with prolog and epilog code. Inlined
functions don't have this overhead.
Eric