<?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>Please can you add extern &amp;quot;C&amp;quot; as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/2590/please-can-you-add-extern-c-as-appropriate-to-your-header-files</link><description>Hi, 
 Many of us use C++ rather than C (as it is superior in every way). When including many of the Nordic SDK header files it is necessary to wrap them in 
 extern &amp;quot;C&amp;quot; {
}
 
 to get the proper linkage. Otherwise you get cryptic error messages like</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 19 May 2018 05:01:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/2590/please-can-you-add-extern-c-as-appropriate-to-your-header-files" /><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/132539?ContentTypeID=1</link><pubDate>Sat, 19 May 2018 05:01:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d06e820-72d1-4389-a208-9df1dce24932</guid><dc:creator>Peter Kenyon</dc:creator><description>&lt;p&gt;I am using SDK 15 and I noticed that&amp;nbsp;&lt;strong&gt;nrf_pwr_mgmt.h&lt;/strong&gt; is missing the C++ guards, so an easy fix for the next release.&lt;/p&gt;
&lt;p&gt;Also I had an issue with.. lines 205 in app_util.h&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifdef __GNUC__
#define STATIC_ASSERT_SIMPLE(EXPR)      //_Static_assert(EXPR, &amp;quot;unspecified message&amp;quot;)
#define STATIC_ASSERT_MSG(EXPR, MSG)    //_Static_assert(EXPR, MSG)
#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;The approach I have adopted is to define the state of the app using a set of vtables (classes) so C++ is essential.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;I am using the excellent SES and C++ 11&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10270?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 18:34:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23f21589-eac2-4e82-8c39-48cc62dce7e1</guid><dc:creator>Christopher</dc:creator><description>&lt;p&gt;From SDK11, the header files of SoftDevices s130 and s130 now include the &lt;code&gt;#ifdef __cplusplus&lt;/code&gt; wrapper. Unfortunately, the header files of the SDK (hal, drivers, libraries) have not been updated yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10266?ContentTypeID=1</link><pubDate>Wed, 18 Jun 2014 15:50:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:975b7dc0-76fb-4f38-a261-bf12b06cd9d4</guid><dc:creator>Andrew Kohlsmith</dc:creator><description>&lt;p&gt;I think including the guards is a great idea but I admit I did laugh out loud at the claim of total superiority. :-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10269?ContentTypeID=1</link><pubDate>Fri, 06 Jun 2014 17:41:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c79f6b02-f546-48c3-9c6b-870d19f02f20</guid><dc:creator>Eirik Midttun</dc:creator><description>&lt;p&gt;If you ask me it is matter of habit; looks strange if you are not used to it. Andrew has a fair point that the mbed platform is supported. That does make a case for including the C++ include guards as suggested.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10268?ContentTypeID=1</link><pubDate>Fri, 06 Jun 2014 13:12:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8cbb7620-82d3-4a14-ac08-3dd408df1de7</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;That does work, it&amp;#39;s just inconvenient and error-prone (sometimes you forget). It&amp;#39;s like if you had to do all your own #include guards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10265?ContentTypeID=1</link><pubDate>Wed, 28 May 2014 11:44:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4656a71b-5d3d-41d5-8269-095eb3a5b936</guid><dc:creator>Andrew Fernandes</dc:creator><description>&lt;p&gt;I would vote for the C++ include guards, too!&lt;/p&gt;
&lt;p&gt;This is standard style if a C interface supports C++, even if &amp;quot;support&amp;quot; means &amp;quot;is not painful to use&amp;quot;. Cognitive style is very important in C, so using &amp;quot;standard&amp;quot; idioms, such as __cplusplus guards, really helps take the cognitive load off of a developer.&lt;/p&gt;
&lt;p&gt;Also, the mbed platform is C++ only, and I know that Nordic is supporting that, so I would assume that C++ is actually, to some extent, already supported by Nordic using a mbed branch of the SDK!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10264?ContentTypeID=1</link><pubDate>Wed, 28 May 2014 08:47:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc08e41-10b9-4d32-a611-fd95e4cf2c57</guid><dc:creator>Joe Merten</dc:creator><description>&lt;p&gt;As I&amp;#39;m also using C++ (gcc-arm) with Nordic Sdk, I&amp;#39;m with you. Using extern &amp;quot;C&amp;quot; { #include &amp;quot;sdklib.h&amp;quot; } in every of my C++ sources works, but appears a bit ugly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10267?ContentTypeID=1</link><pubDate>Tue, 27 May 2014 19:55:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:137bc225-0587-4134-9855-599cca8a4ded</guid><dc:creator>Eirik Midttun</dc:creator><description>&lt;p&gt;The header files don&amp;#39;t have the extern &amp;quot;C&amp;quot; wrapping because the SDK isn&amp;#39;t designed with C++ in mind. As long as that is the decision I don&amp;#39;t think the header files should include C++ directives for mere convenience.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m a bit unsure how you actually wrap from the question, but I see nothing wrong with something like this in a .cpp file:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;extern &amp;quot;C&amp;quot; {
#include &amp;quot;sdklib.h&amp;quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is that so difficult? I would prefer it like this this; it is a nice reminder that sdklib is in pure C, not C++ as the rest of the code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10263?ContentTypeID=1</link><pubDate>Wed, 21 May 2014 12:52:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a314f9c-591c-4379-93a5-780ae70399cc</guid><dc:creator>Nguyen Hoan Hoang</dc:creator><description>&lt;p&gt;I second you on this.  It MUST always be there for all exposed C function.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Please can you add extern "C" as appropriate to your header files?</title><link>https://devzone.nordicsemi.com/thread/10262?ContentTypeID=1</link><pubDate>Wed, 21 May 2014 12:23:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3e65b9e-4b8a-467f-b54b-686a11abd9ca</guid><dc:creator>Tim</dc:creator><description>&lt;p&gt;Actually the &amp;quot;impossible constraint in &lt;code&gt;asm&lt;/code&gt;&amp;quot; issue was something else, but the point still stands.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>