[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] generic queue library for AVR GCC?
From: |
Dave Hansen |
Subject: |
Re: [avr-gcc-list] generic queue library for AVR GCC? |
Date: |
Wed, 17 Nov 2004 14:46:54 -0500 |
From: Andy Warner <address@hidden>
Bruce D. Lightner wrote:
[...]
> #define begin_critical_section() SREG, cli()
> #define end_critical_section(val) SREG = val
> ....
> {
> unsigned char sreg = begin_critical_section();
Is that going to work the way you expect it to ?
I don't think so.
But
unsigned char sreg;
sreg = begin_critical_section();
should definitely work.
I understood that the comma operator returns the type and
value of the rightmost statement (which will be cli()
in this example.)
But the comma operator has lower precedence than the assignment operator.
So
sreg = SREG, cli();
should parse as
(sreg = SREG), (cli());
Which is why I question the original code, which mixes in a declaration.
The = in the declaration is not an assignment operator, so I suspect that
will parse as
unsigned char sreg = (SREG, cli());
as you suggest.
Regards,
-=Dave
- Re: [avr-gcc-list] generic queue library for AVR GCC?, (continued)
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Theodore A. Roth, 2004/11/17
- Message not available
- Re: [avr-gcc-list] generic queue library for AVR GCC?, E. Weddington, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, rusty+avr-gcc-list, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Theodore A. Roth, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Bruce D. Lightner, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Theodore A. Roth, 2004/11/15
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Geoffrey Wossum, 2004/11/16
Re: [avr-gcc-list] generic queue library for AVR GCC?,
Dave Hansen <=