avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: static class member as interrupt handler works, but not if class is


From: Anton Staaf
Subject: Re: static class member as interrupt handler works, but not if class is templated
Date: Sat, 10 Apr 2021 20:40:44 -0700

For those that care, and ignoring the flame war, I believe that your (Klaus) problem likely stems from the following GCC bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70435

Sadly, support for C++ in AVR GCC is not a priority, so I wouldn't expect it to be fixed.  I've been able to work around this myself using explicit template instantiation, because I'm relying on a slightly different attribute that isn't propgated correctly.  I'm tagging an object as living in the .vectors section, and making its memory layout match the vector table layout for AVR processors.  This lets me generate only the vectors that are required using template meta programming based on the interrupts that are listened for.  I've built my avr-gcc with "--with-avrlibc=no" and "--without-newlib" to suppress the misspelled ISR warning.

-Anton

On Sat, Apr 10, 2021 at 8:19 PM Russell Shaw <rjshaw@netspace.net.au> wrote:
On 11/4/21 8:36 am, Trampas Stern wrote:
> Actually C++ is not slower or more bloat than C, depending on the features used.
>
> For example I do not use RTTI or exceptions, so that makes it about the same as
> C for size. Yes you have to turn these features off in your compiler (-fno-rtti,
> -fno-exceptions).  Sure you have trampolines or jump tables for function
> overloading but you have to do the same in C. If you do not use inheritance or
> function overloading you do not have the penalty.

Function overloading is a compile-time concept, but the result after name scope
flattening are simple function names that are called without any extra pointer
indirections (ie, no different than C).

C++ is as efficient as C only if what is written translates to the equivalent
form. This is easy to do, but only after a large hurdle of understanding how C++
compilers work.

The biggest shortcoming in the C++ "industry" is that there is no literature i
have seen that explains in a compact way how you can look at a piece of C++ code
and see how it would translate to the equivalent assembly, which is the main
advantage of C.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]