Mangle functions
Daniel Lohmann
daniel.lohmann@informatik.uni-erlangen.de
Tue Jan 29 00:54:00 GMT 2008
On 28.01.2008, at 13:11, Ron Kreymborg wrote:
>> BTW: In your example you used a non-static method. You probably know
>> that you have to make sure that the this-pointer is passed
>> accordingly
>> in this case.
>
> The interrupt class does not need a this pointer as it neither calls
> other
> methods in its class or accesses any private class data, so the
> interrupt
> method itself can correctly be non-static.
Well, "correctly" is a bit strong here. In fact, the behaviour is
undefined and it is just a case of luck (read: compiler-specifica)
that it works. Whereas depending on compiler-specifica is acceptable
for programming on this level, it is just not necessary in your case.
So why do you not just make it a class function (static) instead of a
member function? They can be private as well, friends as well, their
calling semantics is defined, and the *compiler* would make sure that
you do not (accidentally) access any member elements. No
disadvantages, but more safety.
Moreover, class functions can be given "C" linkage. Andrew is right
with his comments that this would be the cleaner solution. The asm-
Statement solution is, however, a suitable alternative if you want to
encode the class name into the symbol name for scoping purposes, which
becomes necessary if the IRQ handler methods should always have the
same name in different driver classes.
Daniel
More information about the Gcc-help
mailing list