<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/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/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Using C++ std::exceptions with NCS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/81573/using-c-std-exceptions-with-ncs</link><description>Hi, 
 we&amp;#39;re using a library which is written in C++ and is using exceptions. As stated here Zephyr has C++ support including exceptions. 
 Following the docs I set 
 
 But this leads to a linker error: fini.c:(.text.__libc_fini_array+0x20): undefined</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 12 Nov 2021 09:07:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/81573/using-c-std-exceptions-with-ncs" /><item><title>RE: Using C++ std::exceptions with NCS</title><link>https://devzone.nordicsemi.com/thread/338706?ContentTypeID=1</link><pubDate>Fri, 12 Nov 2021 09:07:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28b49684-805f-46d4-b76a-f1c1ddc997a1</guid><dc:creator>OliverB</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&amp;Oslash;yvind,&lt;/p&gt;
&lt;p&gt;thanks for your suggestion. It&amp;#39;s definitely a good place to get Zephyr related help.&lt;/p&gt;
&lt;p&gt;For those that might run into the same issue, here&amp;#39;s my solution:&lt;/p&gt;
&lt;p&gt;In prj.conf you need the C++ and exceptions related stuff:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="markdown"&gt;...
CONFIG_CPLUSPLUS=y
CONFIG_LIB_CPLUSPLUS=y

CONFIG_NEWLIB_LIBC=y
CONFIG_EXCEPTIONS=y
CONFIG_NEWLIB_LIBC_NANO=n
...&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To prevent the linker error, I had to implement following function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void exit(int reason) {
  printk(&amp;quot;EXIT %d&amp;quot;, reason);
  while (1)
    ;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Now the code compiles without error and the exceptions are being catched. But Interestingly exit() is being called.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using C++ std::exceptions with NCS</title><link>https://devzone.nordicsemi.com/thread/338292?ContentTypeID=1</link><pubDate>Wed, 10 Nov 2021 07:22:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71d11378-121c-4c11-be72-d94c16d0d3cd</guid><dc:creator>&amp;#216;yvind</dc:creator><description>&lt;p&gt;Hello Oliver,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;This is unfortunately nothing we can assist with as this is part of the Zephyr RTOS. Please reach out to the &lt;a href="https://discord.com/invite/Ck7jw53nU2"&gt;Zephyr community through their Discord channel&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Øyvind&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>