[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: |
Theodore A. Roth |
Subject: |
Re: [avr-gcc-list] generic queue library for AVR GCC? |
Date: |
Wed, 17 Nov 2004 11:47:43 -0800 (PST) |
On Wed, 17 Nov 2004 address@hidden wrote:
> Bruce is beating that poor dead horse with a wet noodle. ;)
Let's please not degenerate this discussion even if it is a dead horse.
Bruce is actually correct. [See below.]
> Bruce D. Lightner wrote:
> > [...]
> > You all of course know that "," can be used in place of ";" to
> > separate C statements. Therefore we can make a minor change to
> > the first macro definition...
> > [...]
> > #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 understood that the comma operator returns the type and
> value of the rightmost statement (which will be cli()
> in this example.)
You are partially correct.
Here's a simple program that shows that the right thing is done:
#include <stdio.h>
int get_a (void) { return 'A'; }
int get_b (void) { return 'B'; }
int main (void)
{
int ch;
if (get_a () == 'A') ch = get_a (), get_b ();
printf ("ch = %c\n", ch);
ch = get_a (), get_b ();
printf ("ch = %c\n", ch);
ch = ( get_a (), get_b () );
printf ("ch = %c\n", ch);
return 0;
}
Compiling that on linux and running it yields:
address@hidden:~$ ./foo
ch = A
ch = A
ch = B
---
Ted Roth
PGP Key ID: 0x18F846E9
Jabber ID: address@hidden
- Re: [avr-gcc-list] generic queue library for AVR GCC?, (continued)
- Re: [avr-gcc-list] generic queue library for AVR GCC?, David Brown, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Bruce D. Lightner, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Andy Warner, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, rusty+avr-gcc-list, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Bruce D. Lightner, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Ben L. Titzer, 2004/11/17
- Re: [avr-gcc-list] generic queue library for AVR GCC?, E. Weddington, 2004/11/18
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Ben L. Titzer, 2004/11/18
- Re: [avr-gcc-list] generic queue library for AVR GCC?, E. Weddington, 2004/11/18
- Re: [avr-gcc-list] generic queue library for AVR GCC?, Ben L. Titzer, 2004/11/18
- Re: [avr-gcc-list] generic queue library for AVR GCC?,
Theodore A. Roth <=
- 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, 2004/11/17