For the C++ code below, I am getting
error: specialization of 'static void ISR<N>::handler() [with unsigned int N = 5]' after instantiation
9 | void ISR<5>::handler()
|
when compiled with
$ avr-gcc -mmcu=atmega8 foo.cpp -mmcu=atmega8
Notice that signal(n)
is a recent addition to GCC v15. I found Specialization of member function template after instantiation error, and order of member functions however I don’t see how to apply that solution to the code below.
template<unsigned N>
struct ISR
{
__attribute__((__signal__(N)))
static void handler();
};
template<>
void ISR<5>::handler()
{
__asm ("nop");
}
int main (void)
{
return 0;
}
The code compiles as expected without the function attribute.
What’s also strange is that it works with, say [[gnu::naked]]
but not with [[gnu::signal]]
.