[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Comma Operator in #define
From: |
E. Weddington |
Subject: |
Re: [avr-gcc-list] Comma Operator in #define |
Date: |
Tue, 22 Jul 2003 22:01:05 GMT |
> Maybe I'm missing something, but I *did* check the ANSI C
manual, and this
> should be OK, I think.
>
> I want to use a comma operator in a macro (#define)
statement:
>
> #define set_clock(x) asm volatile("nop\n\t"::), (PORTB |=
BIT3)
>
> avr-gcc gives the following error when I use this macro:
>
> set_clock();
>
> error: parse error before ',' token
>
> If I just make it a ';', then everything works OK.
>
> Any ideas? What am I doing wrong? Or is this a bug?
>
AFAIK, the define body is composed of 2 seperate C
statements which should be seperated by semicolon. A comma
does not seperate C statements; a semicolon seperates C
statements. (Sometimes in English too. ;-))
It's not a matter of whether a comma is allowed in macro,
as so much whether the macro is defined to be legal C.