AVR-GCC a expanze makro
Hynek Sladky
econf@centrum.cz
Středa Prosinec 7 08:50:27 CET 2005
Neslo. Na zacatku programu mam totiz neco takoveho:
#define LED PORTA, 0
#define BUZZER PORTA, 1
#define RELE PORTA, 2
Uz jsem nasel tri moznosti, jak by to melo fungovat, lec pro me
pouzitelna je jen jedna (jedna se v avr-gcc preklada spatne, druha je
slozitejsi na nadefinovani):
#define pinset__(port,bit) port|=(1<<bit)
#define pinset(...) pinset__(__VA_ARGS__)
V kodu pak muzu psat:
pinset (LED);
pinset (BUZZER);
Hynek Sladky
Zdenek Janis wrote:
> a takhle by to neslo?
>
> #define mujport PORTA
> #define mujpin 0
>
> #define pinset(bit) mujport |= (1<<bit)
>
> void fnc() {
> pinset(mujpin);
> }
>
>
> Hynek Sladky wrote:
>
>>#define pinset(port,bit) port |= (1<<bit)
>>#define mujpin PORTA, 0
>>
>>funkce () {
>> pinset (mujpin);
>>}
>>
>>Prekladac ale hlasi:
>>eval.c:87:13: macro "pinset" requires 2 arguments, but only 1 given
>>eval.c: In function `funkce':
>>eval.c:87: error: `pinset' undeclared (first use in this function)
>
>
Další informace o konferenci Hw-list