<?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>Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69579/programming-nrf52-dk-in-c-in-segger-embedded-studio</link><description>Hi. 
 I am writing software for my custom nRF52832 device but hardware wise it is identical to the nRF52 DK. 
 I&amp;#39;m not that good of an embedded coder (or any kind of coder for that matter) and I am trying to integrate some i2c sensors on my device. 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 Feb 2021 10:26:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69579/programming-nrf52-dk-in-c-in-segger-embedded-studio" /><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/293055?ContentTypeID=1</link><pubDate>Fri, 05 Feb 2021 10:26:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee637dbf-07d5-4d4a-b559-0fef7dbc0304</guid><dc:creator>Bhaveesh</dc:creator><description>&lt;p&gt;Thanks, it works with sdk&amp;nbsp;&lt;span&gt;v17.0.2.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/292826?ContentTypeID=1</link><pubDate>Thu, 04 Feb 2021 08:19:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db6585d3-525a-42c1-9a4f-3fab87c60e8b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you try the example in SDK v17.0.2?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There were some changes in how the RAM segments are set up between SDK v17.0.0 and v17.0.2, and I expect this to be the problem in your case.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/292672?ContentTypeID=1</link><pubDate>Wed, 03 Feb 2021 12:54:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cbb2419-360b-4a60-b86a-015f6c7d5534</guid><dc:creator>Bhaveesh</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span class="user-name"&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;Thanks for your sample example.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;When I try to compile this example. Linker throws following error.&lt;br /&gt;&lt;br /&gt;1&amp;gt; Linking ble_app_uart_pca10056_s140.elf&lt;br /&gt;C:\Users\Kumarbhv\Downloads\nRF5_SDK_17.0.0_9d13099\modules\nrfx\mdk/ses_startup_nrf_common.s:110: undefined reference to `__RAM_segment_end__&amp;#39;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;Can you please help me with that?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/288529?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2021 07:34:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70479d2d-a836-4b5e-bc16-10115a40ab3a</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;You welcome Usman, good to hear you got it working &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/288338?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2021 10:39:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3516cff-08a6-4fb2-ba9d-2d8cf9862b5a</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;--- edit ---&lt;/p&gt;
&lt;p&gt;After I removed&amp;nbsp;&lt;em&gt;static&lt;/em&gt; from&amp;nbsp;&lt;em&gt;static void idle_state_handle(void)&lt;/em&gt;, it all compiled perfectly.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks again. :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/288334?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2021 10:32:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46ca264f-5d6d-483f-9239-811a5f4049b3</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi Shiv.&lt;/p&gt;
&lt;p&gt;Thank you so much for this helpful guide. It will definitely help me A LOT when I mix my C and C++ code.&lt;/p&gt;
&lt;p&gt;Regards,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/288329?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2021 10:01:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f7b02db-abd2-4b60-aa47-f6d24bd2a939</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you so much for the help.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I took your code and made mine similar to it. It turns out I was misunderstanding the instructions all along, and now the code compiles. Just one little problem left.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Whenever I include the &lt;em&gt;app_idle_state_handle()&lt;/em&gt; in the code, it fails to compile, says &amp;quot;&lt;em&gt;undefined reference to `app_idle_state_handle&amp;#39;&lt;/em&gt;&amp;quot;, even though I know the functioned is fully defined in both .c and .h files. I don&amp;#39;t know why it does this. But when I remove the function call from main.cpp, all works well.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;If I call the same function in the .c file, it works perfectly. If you can provide any guidance with that, that would be great, but it&amp;#39;s not a major issue, since it wasn&amp;#39;t&amp;nbsp;useful to me anyway.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Usman&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/288237?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2021 17:21:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fecc24c-0cb3-4f7e-9374-a5d676163b27</guid><dc:creator>Shivek</dc:creator><description>&lt;p&gt;Hi Usman,&lt;/p&gt;
&lt;p&gt;You can wrap your cpp code with extern C and I have found one reference for you to make it understandable.&lt;/p&gt;
&lt;p&gt;Read this link&amp;nbsp;&lt;a href="https://isocpp.org/wiki/faq/mixing-c-and-cpp#call-cpp" rel="noopener noreferrer" target="_blank"&gt;here&lt;/a&gt;&amp;nbsp;and I hope this would be helpful for you.&lt;/p&gt;
&lt;p&gt;-Shiv&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/288187?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2021 13:16:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98e1b3ca-1d36-4e02-b04b-09e248fa9808</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;I did the same exercise myself based on the ble_app_uart example to illustrate how it can be done:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/261622_5F00_ble_5F00_app_5F00_uart.zip"&gt;devzone.nordicsemi.com/.../261622_5F00_ble_5F00_app_5F00_uart.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Basically I copy the entirety of the main.c file into the separate C file (ble_app.c).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Essentially the only thing I put in the ble_app.h file is the prototype of any function that needs to be called from main.cpp. Everything else I leave in the ble_app.c file, to&amp;nbsp;avoid this being pulled into main.cpp when you include the header file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you try to follow the same approach I expect you should get the example to compile.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/287903?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 10:16:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ad665df-3abb-4faf-b9e8-1ab1152b2221</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Please see&amp;nbsp;&lt;a href="https://gofile.io/d/l955b2"&gt;https://gofile.io/d/l955b2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Its basically the&amp;nbsp;&lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/ble_app_uart__saadc_timer_driven__scan_mode"&gt;ble_app_uart__saadc_timer_driven__scan_mode&lt;/a&gt;&amp;nbsp;example&lt;/p&gt;
&lt;p&gt;Thank you so much for your help.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/287863?ContentTypeID=1</link><pubDate>Thu, 07 Jan 2021 08:29:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2e220f6-2bbf-43d9-a99f-5e5abfebdfe1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;Are you able to share your project with me so I can try it out?&lt;/p&gt;
&lt;p&gt;I can make the case private if you don&amp;#39;t want to share it in public.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/287391?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 06:09:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e2e9df0-a349-432a-8de3-49bee8c9188f</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;After a few attempts, I finally managed to get this working&lt;/p&gt;
[quote userid="94615" url="~/f/nordic-q-a/69579/programming-nrf52-dk-in-c-in-segger-embedded-studio/286967#286967"]And so I tried to compile them with just printf( )[/quote]
&lt;p&gt;and it compiled.&lt;/p&gt;
&lt;p&gt;So I put in my original code in these files, and now it returns the same old error.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;expected constructor, destructor, or type conversion before &amp;#39;(&amp;#39; token&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;How could it be that it is compiling the simple .c file inside the .cpp file perfectly, but as soon as I add my other code to the .c file, it fails to compile? The my code in original .c file itself was compiling and working perfectly.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286973?ContentTypeID=1</link><pubDate>Wed, 30 Dec 2020 09:56:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfb4fe5b-43bf-4c0f-bdc0-35e581be8f3d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;Good point, I forgot to mention this. Every header file that defines functions that you need to include in a C++ file needs to use the extern &amp;quot;C&amp;quot; header, otherwise they won&amp;#39;t be visible to the C++ linker.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you open any of the standard header files in the SDK you can spot this.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Essentially they will have the following somewhere at the top of the header file (after any includes but before any defines or function prototypes):&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#ifdef __cplusplus
extern &amp;quot;C&amp;quot; {
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And then the following at the bottom of the file (before the final #endif):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#ifdef __cplusplus
}
#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286967?ContentTypeID=1</link><pubDate>Wed, 30 Dec 2020 09:44:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24ed9bbf-4996-4129-8449-ad8ce4b4d5d5</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Yes, I tried that as well. But no good.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And so I tried to compile them with just printf( ) in it and here&amp;#39;s what my files look like:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;main.cpp:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="batchfile"&gt;#include &amp;quot;c_file.h&amp;quot;

int main(void)
{
    func();
}&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;c_file.h:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef CFile_H
#define CFILE_H

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

int func();

#endif &lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;c_file.c:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef CFile_C
#define CFILE_C

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

int func()
{
    printf(&amp;quot;this c file&amp;quot;);
    return 0;
}

#endif &lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And it gives me this error:&amp;nbsp;&lt;em&gt;undefined reference to `func()&amp;#39;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Am I doing something wrong here?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286959?ContentTypeID=1</link><pubDate>Wed, 30 Dec 2020 09:30:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:102264c9-5368-49a7-a8c9-4fd14b07ac76</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;Did you move all the instance definitions at the top of main.c into the separate file?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;They should look something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;BLE_NUS_DEF(m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);                                   /**&amp;lt; BLE NUS service instance. */
NRF_BLE_GATT_DEF(m_gatt);                                                           /**&amp;lt; GATT module instance. */
NRF_BLE_QWR_DEF(m_qwr);                                                             /**&amp;lt; Context for the Queued Write module.*/
BLE_ADVERTISING_DEF(m_advertising);                                                 /**&amp;lt; Advertising module instance. */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;These macros will not compile in C++, and they will also have to be available to the rest of the BLE code if you move this into a separate file.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286782?ContentTypeID=1</link><pubDate>Tue, 29 Dec 2020 05:01:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ce372a5-f81e-4d6c-babf-9d756501ef4a</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for the correction. I&amp;nbsp;did exactly as you told, but it still gives the same old errors&lt;/span&gt;&lt;/p&gt;
[quote userid="94615" url="~/f/nordic-q-a/69579/programming-nrf52-dk-in-c-in-segger-embedded-studio/285764#285764"]&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://ibb.co/nD623Tz"&gt;&lt;span class="ui-webpreview"&gt;&lt;div class="abbreviated-post-header shared-link"&gt;&lt;/div&gt;&lt;div class="abbreviated-post shared-link  with-image "&gt;   &lt;h4 class="post-name"&gt;&lt;a href="https://ibb.co/nD623Tz" class="external-link" target="_blank" rel="nofollow"&gt;Capture&lt;/a&gt;&lt;/h4&gt;          &lt;div class="post-application"&gt;           &lt;span class="label"&gt;&lt;/span&gt;           &lt;span class="value"&gt;&lt;a href="https://ibb.co/nD623Tz" class="external-link" target="_blank" rel="nofollow"&gt;ImgBB&lt;/a&gt;&lt;/span&gt;       &lt;/div&gt;             &lt;div class="post-thumbnail"&gt;           &lt;a href="https://ibb.co/nD623Tz" class="external-link" target="_blank" rel="nofollow"&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/90x90x2/__key/webpreviewimages/bbc20d9e0ef1404fab28a69e0ce16017/Capture.png" border="0" alt=" " /&gt;&lt;/a&gt;       &lt;/div&gt;             &lt;div class="post-summary"&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;I even tried removing ALL code from the cpp file and just put a printf( ) just to see if that works, but doesn&amp;#39;t compile either. At this point, I think its more of a configuration issue, but I could be wrong.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any guidance would be highly appreciated.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286314?ContentTypeID=1</link><pubDate>Tue, 22 Dec 2020 13:43:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9de4554-ff20-43f7-9158-85af8271605b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;First off you shouldn&amp;#39;t include a C file from another C file. Instead you need to create a header file&amp;nbsp;(c_file.h essentially) that contains the function prototypes for the functions in c_file.c that you need to access, and include this header file only from main.c.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, in this file I would suggest splitting the code into a couple of independent functions for doing things such as:&lt;/p&gt;
&lt;p&gt;- Initializing the Bluetooth stack&lt;br /&gt;- Starting advertising&lt;br /&gt;- Sending or receiving data from a connected device&lt;br /&gt;- anything else that your application needs to do over Bluetooth&lt;/p&gt;
&lt;p&gt;In the end your main file could look something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void on_ble_event(app_ble_event_t *event)
{
    switch(event-&amp;gt;type)
    {
        case APP_BLE_EVT_DATA_RECEIVED:
            break;
        case APP_BLE_EVT_CONNECTED:
            break;
            
        // And any other events you need to send back to the main function
    }            
}

int main(void)
{
    app_ble_initialize(/*Arguments here*/);
    app_ble_set_callback(on_ble_event);
    
    app_ble_start_advertising();
    
    // Main loop
    while(1)
    {
        // If you have something to do repeatedly in the main loop in c_file.c then you can call it from here:
        app_ble_execute();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hopefully this makes sense?&lt;br /&gt;Please note that my pseudo code suggestion above is not the only way to do it, but I think it&amp;#39;s a good way to move the details of configuring and managing the Bluetooth stack into a separate file (I think it&amp;#39;s a good idea to do this even if you don&amp;#39;t need to compile your project for C++).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286208?ContentTypeID=1</link><pubDate>Tue, 22 Dec 2020 06:17:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1a0ab49-1911-4fca-ad49-88d90e37e406</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
[quote userid="2116" url="~/f/nordic-q-a/69579/programming-nrf52-dk-in-c-in-segger-embedded-studio/286007#286007"] you move the BLE functionality out of the main file and into a separate C file (that you can then call from the main.cpp file)[/quote]
&lt;p&gt;I did this, now my code is like this, but it shows the exact same errors.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If I remove #include &amp;quot;c_file.c&amp;quot; from the top, and mainx() in the main function, then it compiles. But now with them. What am I doing wrong here?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;c_file.c&amp;quot;

int main(void)
{
    mainx();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks, and regards,&lt;/p&gt;
&lt;p&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286018?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 11:21:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ce574799-2c0c-4b40-917b-b85810f319dd</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Torbj&amp;oslash;rn.&lt;/p&gt;
&lt;p&gt;Thanks for the insight. It&amp;nbsp;makes a lot of sense, since I&amp;#39;m using ble_app_uart example as a base.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So what I should do is, make a main.cpp file, put my non BLE code into it, rename the old main.c file into something else, and call the .c file in my main.cpp file?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/286007?ContentTypeID=1</link><pubDate>Mon, 21 Dec 2020 10:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bce45c76-a795-49b0-b030-cba8b0268953</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;Which example are you using?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately many of the API&amp;#39;s in the SDK, including several of the BLE API&amp;#39;s, don&amp;#39;t support C++. As such the standard example will not build in C++, unless you move the BLE functionality out of the main file and into a separate C file (that you can then call from the main.cpp file).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/285764?ContentTypeID=1</link><pubDate>Fri, 18 Dec 2020 08:44:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9fde417-a6e1-4527-9f7c-cd6deedd86f7</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn. Thanks for the information.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I did just that and got a plethora&amp;nbsp;of&amp;nbsp; errors.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://ibb.co/nD623Tz"&gt;https://ibb.co/nD623Tz&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;How do I fix these?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Usman&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/285761?ContentTypeID=1</link><pubDate>Fri, 18 Dec 2020 08:22:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fefd41e5-adca-4bd6-b29c-5e43f3bf6ebe</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;This will happen if you try to include a C++ header file in a C file, since the C file will be compiled using the C compiler.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Any source file where you want to access C++ libraries will itself need to be a C++ file, which means you have to make the main.c file into a main.cpp file if you want to call C++ libraries from main.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/285550?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 09:29:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9889feab-ba0a-4feb-b49f-315c7924a2d7</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Torbj&amp;oslash;rn, thanks for pointing that out.&lt;/p&gt;
&lt;p&gt;When I compile, it gives this error where the object class is defined&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;unknown type name &amp;#39;class&amp;#39;&lt;/pre&gt;&lt;br /&gt;What am I missing here? &lt;br /&gt;Regards&lt;br /&gt;Usman&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/285548?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 09:21:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7a5c8e3-9757-4c76-8a7c-45378f7fae5d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Usman&lt;/p&gt;
&lt;p&gt;Any .cpp file should automatically be compiled using the C++ compiler, while any .c files will be compiled by the C compiler, so it should be possible to mix and match C and C++ code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There might be library files in the SDK that will not compile in C++, because they use language features only available in C, but it should be possible to get around this by using C++ for your sensor libraries only.&lt;/p&gt;
&lt;p&gt;Have you tried to integrate any .cpp files in your project?&lt;/p&gt;
&lt;p&gt;If yes, did you face any issues?&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Programming nRF52 DK in C++ in Segger Embedded Studio</title><link>https://devzone.nordicsemi.com/thread/285425?ContentTypeID=1</link><pubDate>Wed, 16 Dec 2020 16:03:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87eb460e-2712-4e4c-93b3-f9b9b9aa1b01</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;I do know C++, but the question is about something else.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>