<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC Microcontrollers中的主题 Re: Interrupt handlers and the C++ compiler [SOLVED]</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-handlers-and-the-C-compiler-SOLVED/m-p/513329#M123</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Wed Dec 24 17:03:47 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: fjrg76&lt;/STRONG&gt;&lt;BR /&gt;Why is so? Because C++ adds some characteres to the name of the functions (or methods).&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That's 'Name mangling'&amp;nbsp; :) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;See. &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FName_mangling" rel="nofollow" target="_blank"&gt;http://en.wikipedia.org/wiki/Name_mangling&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:06:11 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:06:11Z</dc:date>
    <item>
      <title>Interrupt handlers and the C++ compiler [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-handlers-and-the-C-compiler-SOLVED/m-p/513328#M122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fjrg76 on Wed Dec 24 16:58:15 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I faced an issue for the interrupt handlers while compiling my C++ application. I solved it already, but I want to post my solution in case you'll find yourself struggling with the same problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;General solution:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;When mixing C and C++ code for the same project one needs to place the C code in between&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;#ifdef __cplusplus
extern "C" {
#endif

/* here your C functions (prototypes or declarations */

#ifdef __cplusplus
}
#endif&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;Particular solution:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What I did was to embrace the interrupt handler in between the preprocessor directives&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;#ifdef __cplusplus
extern "C" {
#endif&amp;nbsp; 
void SysTick_Handler(void)
{
if (sleep.IsRunning()) {
--sleep;
if (sleep.Get() &amp;lt; 1) {
sleep.Stop();
}
}
}
#ifdef __cplusplus
}
#endif&amp;nbsp; &lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Otherwise the compiler will use the default &lt;/SPAN&gt;&lt;I&gt;SysTick_Handler()&lt;/I&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;__attribute__ ((section(".after_vectors")))
void SysTick_Handler(void)
{ while(1) {}
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Why is so? Because C++ adds some characteres to the name of the functions (or methods). So, for the compiler (if you don't use the preprocessor guards) the function &lt;/SPAN&gt;&lt;BR /&gt;&lt;I&gt;SysTick_Handler&lt;/I&gt;&lt;SPAN&gt; looks like &lt;/SPAN&gt;&lt;I&gt;__SysTick_Handler__&lt;/I&gt;&lt;SPAN&gt; (or something similar), which is naturally very different to what you expect. Using the preprocessor guards you're compeling the compiler to respect the name (among other things).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this post is helpful for you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:06:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-handlers-and-the-C-compiler-SOLVED/m-p/513328#M122</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:06:10Z</dc:date>
    </item>
    <item>
      <title>Re: Interrupt handlers and the C++ compiler [SOLVED]</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-handlers-and-the-C-compiler-SOLVED/m-p/513329#M123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by R2D2 on Wed Dec 24 17:03:47 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: fjrg76&lt;/STRONG&gt;&lt;BR /&gt;Why is so? Because C++ adds some characteres to the name of the functions (or methods).&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That's 'Name mangling'&amp;nbsp; :) &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;See. &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fen.wikipedia.org%2Fwiki%2FName_mangling" rel="nofollow" target="_blank"&gt;http://en.wikipedia.org/wiki/Name_mangling&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:06:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Interrupt-handlers-and-the-C-compiler-SOLVED/m-p/513329#M123</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:06:11Z</dc:date>
    </item>
  </channel>
</rss>

