<?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>Pointer to class instance</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12684/pointer-to-class-instance</link><description>NrfIdentifyCommand identifyCommand;
NrfIdentifyCommand *pIdentifyCommand = &amp;amp;identifyCommand;

int commandId = identifyCommand.GetCommandId(); // works
commandId = pIdentifyCommand-&amp;gt;GetCommandId(); // FAILS (on Devboard going to Nirvana ...)
 
 Why</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Mar 2016 12:01:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12684/pointer-to-class-instance" /><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48175?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 12:01:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0bb7ddc0-8969-43b0-b827-e5faf950292b</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;The Nordic SoftDevices and SDKs do not use the heap at all, but there should be nothing preventing you from using a heap in your software. I have never used a heap for nRF software myself, so I do not know if and how memory settings must be changed for this to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48177?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 08:11:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c69ba26-9c8e-4630-9eb2-e70e5692e7a7</guid><dc:creator>hfrmobile</dc:creator><description>&lt;p&gt;Even the workaround works (see answer) it would be good to know why the code mentioned in the original question fails when running on a Nordic NRF52 devboard. Something special we should know to know about heap/stack on Nordic platform?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48176?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 08:08:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fcbc4c5-1240-4145-8c56-47680d9bce13</guid><dc:creator>hfrmobile</dc:creator><description>&lt;p&gt;Depends what you mean by &amp;quot;port to C++&amp;quot;. Simply compiling C code (with some adjustments) isn&amp;#39;t a port for me. For example &amp;quot;wrapper classes&amp;quot; around the &amp;quot;Nordic C API&amp;quot; (e.g. NrfLed) is a port since taking advantage of the C++ language (ctor, dror, inheritance, ...)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48174?ContentTypeID=1</link><pubDate>Tue, 22 Mar 2016 08:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37949fde-d2e7-4b6c-b101-5172ed97ca27</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;The SDK is written in C, and various C toolchains are supported. As it is C it is relatively easy to port to C++, but it requires workarounds in some places.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48178?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 10:30:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33444d12-490a-48ff-ab5d-0e8faa10fd12</guid><dc:creator>hfrmobile</dc:creator><description>&lt;p&gt;Workaround solution: Create class instance in main.cpp and provide it to others via global pointer ... (but not very beautiful in my view)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48173?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 10:29:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60269d50-a1a0-4f57-a928-822e9b9fc16f</guid><dc:creator>hfrmobile</dc:creator><description>&lt;p&gt;GNU Compiler Collection: &lt;a href="https://en.wikipedia.org/wiki/GNU_Compiler_Collection"&gt;en.wikipedia.org/.../GNU_Compiler_Collection&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;GCC 1.0 was released in 1987.[1] It was extended to compile C++ in December of that year.&lt;/p&gt;
&lt;p&gt;When talking about GCC I am talking about &amp;quot;GNU Compiler Collection&amp;quot; ;-)&lt;/p&gt;
&lt;p&gt;Compiling NRF SDK stuff via C:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin/arm-none-eabi-gcc&lt;/p&gt;
&lt;p&gt;... and C++ via C:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q2/bin/arm-none-eabi-g++&lt;/p&gt;
&lt;p&gt;Btw, why exist there no pre-compiled libraries as on other platforms. Compiling NRF SDK + our project takes about 40 seconds ... that&amp;#39;s quite long compared to Atmel for example ...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48171?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 10:15:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6034a379-bb11-450a-ac1c-65388c66699f</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;gcc is c compiler, g++ is c++ compiler. you sure that you are using gcc?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48172?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 10:12:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:697239b6-d5b9-4042-bb6f-de49ceab6d14</guid><dc:creator>hfrmobile</dc:creator><description>&lt;p&gt;Maybe the issue is GCC related ....&lt;/p&gt;
&lt;p&gt;Sure? See:
&lt;a href="https://devzone.nordicsemi.com/tutorials/7/development-with-gcc-and-eclipse/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;
(e.g. topic &amp;quot;Eclipse Mars IDE for C/C++ Developers&amp;quot;)&lt;/p&gt;
&lt;p&gt;&lt;em&gt;INFO:&lt;/em&gt; When the class instance is instanced on stack, it works. When it is global variable it doesn&amp;#39;t (see code sample above).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Pointer to class instance</title><link>https://devzone.nordicsemi.com/thread/48170?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2016 10:00:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8764da51-99c6-4d0d-8c8c-6d07a996a2a9</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;I don&amp;#39;t think this problem is nordic-related, as nordics don&amp;#39;t support any c++ toolchain&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>