<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Declaring a Class member function as an interrupt handler</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/30911/declaring-a-class-member-function-as-an-interrupt-handler</link><description> 
Hi. 

 
I&amp;#39;m trying to use a member function of a static class as an
interupt handler. I can handle interrupts in C++ file by creating a
function with the same name as in startupxx.s file and declare it
with extern&amp;quot;C&amp;quot; but i&amp;#39;m unable to do the same in</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Declaring a Class member function as an interrupt handler</title><link>https://community.arm.com/thread/80452?ContentTypeID=1</link><pubDate>Sun, 05 Aug 2012 06:52:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b519dc05-ced6-41c3-8bd2-193812704f0c</guid><dc:creator>Trky Pkt</dc:creator><description>&lt;p&gt;&lt;p&gt;
Thanks alot. I hope to access private member variables and call
private functions of the class inside an interrupt hadler function.
Thats why i tried to declare the member function as an interrupt
handler. I see that it is impossible to pass hiden &amp;quot;this&amp;quot; parameter
to interrupt handler. I had missed this issue. Thanks for help.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Declaring a Class member function as an interrupt handler</title><link>https://community.arm.com/thread/60997?ContentTypeID=1</link><pubDate>Sun, 05 Aug 2012 03:12:44 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5b3d9848-296f-4a08-a7c0-bbb6bdb496a7</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;I&amp;#39;m trying to use a member function of a static class as an
interupt handler.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That begs the question: why? You already know how to do it without
that additional requirement. So why make like more difficult for no
tangible benefit?&lt;/p&gt;

&lt;p&gt;
There&amp;#39;s absolutely no way to do it for a normal member function,
because interrupt handlers can&amp;#39;t pass any arguments, so there&amp;#39;s no
way to pass the hidden &amp;quot;this&amp;quot; argument. So at most it could be a
class method, a.k.a. &amp;quot;static&amp;quot; member function. But a class method has
virtually no advantage over a stand-alone extern &amp;quot;C&amp;quot; function.&lt;/p&gt;

&lt;p&gt;
If all else breaks, you can always call your C++ class member
directly from an extern &amp;quot;C&amp;quot; interrupt handler and be done with it, at
the price of a small run-time overhead which the compiler can
probably optimize away.&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;function with the same name as in startupxx.s file and declare
it with extern&amp;quot;C&amp;quot; but i&amp;#39;m unable to do the same in class member
function.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
That&amp;#39;ll be because the actual name of a C++ method is rather
different from what you typed in your source. I suggest you look up
&amp;quot;name mangling&amp;quot; in your C++ textbooks for further explanation.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Declaring a Class member function as an interrupt handler</title><link>https://community.arm.com/thread/67631?ContentTypeID=1</link><pubDate>Sat, 04 Aug 2012 21:41:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fc1d99d1-9650-4681-b144-08f171f5dd9f</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
There is a bit of information missing.&lt;/p&gt;

&lt;p&gt;
&amp;quot;I am unable to&amp;quot;, doesn&amp;#39;t really tell much. Unable in which way?
You don&amp;#39;t tell us if you have an issue with symbol names, or stack
frames or something else.&lt;/p&gt;

&lt;p&gt;
Further, you haven&amp;#39;t told us what processor you have, so we don&amp;#39;t
know what special requirements there may be for stack handling of the
ISR.&lt;/p&gt;

&lt;p&gt;
But note also that that C++ has different rules for external
naming of symbols, to support type-safe linking and multiple
functions with same name but taking different types of parameters.
extern &amp;quot;C&amp;quot; informs the C++ compiler that a function need to be
compatible with C code.&lt;/p&gt;

&lt;p&gt;
Always try to give as full explanation as possible, when asking
questions.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>