<?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>Zephyr and using C++ code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92203/zephyr-and-using-c-code</link><description>I&amp;#39;m considering transitioning a product codebase to the nRF family (nRF52 or nRF53). 
 It&amp;#39;s Arduino code, with lots of C++ code. 
 As in the cpp_synchonization example provided with Zephyr, I can compile code with a C++ class defines in the CPP file.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 22 Sep 2022 16:59:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92203/zephyr-and-using-c-code" /><item><title>RE: Zephyr and using C++ code</title><link>https://devzone.nordicsemi.com/thread/387558?ContentTypeID=1</link><pubDate>Thu, 22 Sep 2022 16:59:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a5b1354-14d2-41aa-b350-a0ebe578721a</guid><dc:creator>David Elvig </dc:creator><description>&lt;p&gt;Beautiful!&lt;/p&gt;
&lt;p&gt;Fixed with your suggestions.&lt;/p&gt;
&lt;p&gt;I needed to also add&amp;nbsp;&lt;em&gt;&lt;span style="text-decoration:underline;"&gt;extern &amp;quot;C&amp;quot; {&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span style="text-decoration:underline;"&gt;...&lt;br /&gt;}&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;around the prototype in a c header file I was calling.&lt;/p&gt;
&lt;p&gt;It all compiles and links!&lt;/p&gt;
&lt;p&gt;Source updated &lt;a href="https://github.com/Davidelvig/DaveLED1"&gt;here&lt;/a&gt; if anyone wants to look. &amp;nbsp;I&amp;#39;ll leave this test repo live for a while.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr and using C++ code</title><link>https://devzone.nordicsemi.com/thread/387496?ContentTypeID=1</link><pubDate>Thu, 22 Sep 2022 12:28:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4007197c-3a8c-4e19-8aa3-3c22dfcb24ef</guid><dc:creator>wilu</dc:creator><description>&lt;p&gt;main.c file should be renamed to main.cpp to&amp;nbsp;change the compiler to g++ instead of gcc.&lt;br /&gt;&lt;br /&gt;Do not add&amp;nbsp;src/TestCPP.hpp as a target source, header files are not compiled.&lt;br /&gt;&lt;br /&gt;In main.c file add extern &amp;quot;C&amp;quot; before void main() function.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>