<?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>Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/14847/compiling-c-and-c-code</link><description>We&amp;#39;ve currently only been developing our application in C. We now have a couple of C++ libraries we&amp;#39;d like to use and are having trouble compiling the mixture of C and C++ code. 
 This is the Makefile: http://pastebin.com/M4Wsybxt 
And this is the output</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 17 Sep 2016 14:11:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/14847/compiling-c-and-c-code" /><item><title>RE: Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/thread/56688?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2016 14:11:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:869762c4-165a-4085-b5f5-5f02644a7e98</guid><dc:creator>dingari</dc:creator><description>&lt;p&gt;This is somewhat solved. The c++ compiler didn&amp;#39;t like how the &lt;code&gt;NRF_GPIOTE_INITIAL_VALUE_LOW&lt;/code&gt; was initializing structs.&lt;/p&gt;
&lt;p&gt;Doing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Configure output pins for LEDs
nrf_drv_gpiote_out_config_t out_config = {};
out_config.init_state = NRF_GPIOTE_INITIAL_VALUE_LOW;
out_config.task_pin = false;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;instead of&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_gpiote_out_config_t out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;allowed us to compile.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/thread/56687?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2016 14:08:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bda8b076-4491-425a-93db-04badd5bd1c9</guid><dc:creator>dingari</dc:creator><description>&lt;p&gt;Hi, I solved this issue at the time by going around the &lt;code&gt;GPIOTE_CONFIG_OUT_SIMPLE&lt;/code&gt; macro. Instead just doing&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// Configure output pins for LEDs
nrf_drv_gpiote_out_config_t out_config = {};
out_config.init_state = NRF_GPIOTE_INITIAL_VALUE_LOW;
out_config.task_pin = false;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/thread/56686?ContentTypeID=1</link><pubDate>Sat, 17 Sep 2016 10:43:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca41c6f4-5257-422b-bdca-bd376bc22f84</guid><dc:creator>butch</dc:creator><description>&lt;p&gt;You might try changing from an initializer to an assignment:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_gpiote_out_config_t out_config;
out_config = GPIOTE_CONFIG_OUT_SIMPLE(false);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You might treat this function as C: put it in a separate file and compile it as C, declare it as extern &amp;quot;C&amp;quot; in main and call it from your C++ main.&lt;/p&gt;
&lt;p&gt;These solutions don&amp;#39;t require changing the SDK.  You should not be afraid to change the SDK (but yes, it would require a redo when a new SDK comes out.)&lt;/p&gt;
&lt;p&gt;The SDK partially (not fully) supports C++ compilation (some #ifdef __cplusplus.)  In my experience, you can (but it is not trivial) compile the SDK as C++ with just a few changes.  The main thing that bit me was: if you define any IRQ handlers to override the default, make sure to declare then as extern &amp;quot;C&amp;quot; so the names aren&amp;#39;t mangled.  You can use the &amp;quot;nm&amp;quot; command to examine .o and .bin files to see what names are mangled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/thread/56685?ContentTypeID=1</link><pubDate>Thu, 30 Jun 2016 12:36:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34d2085d-0843-4ed6-b391-80950c14a8ee</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Well it does not depends on Eclipse.  Eclipse is just an IDE, it has nothing to do with C++.  If you read the post, you&amp;#39;ll find what needed to be changed in the SDK to make it work for C++.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/thread/56684?ContentTypeID=1</link><pubDate>Thu, 30 Jun 2016 09:37:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0aecef1-0342-42df-82cd-22bef2326422</guid><dc:creator>dingari</dc:creator><description>&lt;p&gt;Thanks for the reply, but I was hoping to find a solution that doesn&amp;#39;t require an IDE like Eclipse.&lt;/p&gt;
&lt;p&gt;Is the IDE way the only way to go for compiling C and C++ code for the NRF51822?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Compiling C and C++ code</title><link>https://devzone.nordicsemi.com/thread/56683?ContentTypeID=1</link><pubDate>Wed, 29 Jun 2016 19:10:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19f4983f-5a37-4931-9f05-be1d262aee0c</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;Have a look at this &lt;a href="http://embeddedsoftdev.blogspot.ca/p/ehal-nrf51.html"&gt;blog&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>