[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] assembler macros
From: |
Jamie Lawson |
Subject: |
Re: [avr-gcc-list] assembler macros |
Date: |
Sun, 7 Nov 2004 23:17:17 -0500 (EST) |
On Mon, 8 Nov 2004, Johannes Bauer wrote:
> Jamie Lawson wrote:
>
> >
> > #define _NOP() do { __asm__ __volatile__ ("nop") } while (0)
> >
> > What does the "do while(0)" do?
>
> The "do while(0)" thing is frequently being using in macros to open a
> new scope. Usually it's only used when more than one instruction should
> be execute. Imagine:
>
Ahh yes, I see. Thanks.
> However, in your code, I do not see why you would get an error. Line 100
> is the macro-line, I guess? Should the macro maybe read
>
> #define _NOP() do { __asm__ __volatile__ ("nop"); } while (0)
>
> instead of
>
> #define _NOP() do { __asm__ __volatile__ ("nop") } while (0)
You are correct here. It compiles without complaint with your fix.
> Greetings,
> Johannes
Regards,
Jamie Lawson