This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
static void MyOverflowInterrupt(void) asm("__vector_16") __attribute__ ((signal, __INTR_ATTRS));
Oh, this one is actually easy :-)
You just need another macro-indirection that uses the "stringify" operator (#) of the pre-processor:
lohmann@mocca:~/tmp$ cat test.cpp #define TIMER0_OVF_vect _VECTOR(16) #define _VECTOR(N) __vector_ ## N
#define IRQ_VECTOR(vec) asm(#vec) __attribute__ ((signal, __INTR_ATTRS))
class Timer0 { static void MyOverflowInterrupt(void) IRQ_VECTOR(TIMER0_OVF_vect); }; <<<<
After pre-processing this becomes:
lohmann@mocca:~/tmp$ g++ -E test.cpp
class Timer0 { static void MyOverflowInterrupt(void) asm("TIMER0_OVF_vect") __attribute__ ((signal, __INTR_ATTRS)); }; <<<<
Daniel
P.S. Answers to to the list, please. Other readers might be interested and contribute as well.
Sorry, I was not too clear here. The user does not really know the vector
number, only the "TIMER_OVF_vect" name. So the user definition:
static void MyOverflowInterrupt(void) asm(TIMER0_OVF_vect) __attribute__ ((signal, __INTR_ATTRS));
must end up after macro substitution being presented to the compiler like:
static void MyOverflowInterrupt(void) asm("__vector_16") __attribute__ ((signal, __INTR_ATTRS));
Perhaps not quite so easy :-(
class Timer0 {
static void MyOverflowInterrupt(void) IRQ_VECTOR(TIMER0_OVF_vect);
};
<<<
>>>
lohmann@mocca:~/tmp$ cat test.cpp ; g++ -E test.cpp| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |