<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: library error with C++ application in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154297#M652</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;KJFPE wrote:&lt;BR /&gt;&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you plase the following in your klinker file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;define block HEAP with size = 0x2000, alignment = 8{ };&lt;/P&gt;&lt;P&gt;place in RAM_region {block HEAP};﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it will work&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;it might work, but is it safe?&lt;IMG alt=":robotwink:" class="emoticon emoticon-robotwink" id="robotwink" src="http://freescale.i.lithium.com/i/smilies/16x16_robot-wink.gif" title="Robot wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MQX does all its own memory management (I think).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say we need to kill the C++thead due to an RTOS error.&amp;nbsp; What happens to cout if it is on the heap?&amp;nbsp; There is no explicit malloc. for cout...can cout be deleted?&amp;nbsp; Looks like a recipe for a memory leak?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;﻿My belief is that a C++ thread should be able to be written that runs in MQX without having an externally defined heap. &amp;nbsp; I know that this can be done because PEG+ is integrated with MQX and runs (we already discussed this).&amp;nbsp; But PEG+ might not use stdio libraries so might avoid this issue by "accident"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since MQX insists on taking over the whole processor, startup code, IO pins, timers, device drivers etc. it would be kind of good to know the limitations of a mixed language environment.﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the more general case, I am simply looking for a way to configure either complier or linker or both which permits C++ application code to run on top of MQX as if MQX were a C++ RTL, but safely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the fallback position is to abandon C++ altogether and try to write object oriented "C". ( (void *) pthis-&amp;gt;do_stuff(void * paramset )&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works, but is it a good idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt=":robottongue:" class="emoticon emoticon-robottongue" id="robottongue" src="http://freescale.i.lithium.com/i/smilies/16x16_robot-tongue.gif" title="Robot tongue" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Aug 2011 18:17:19 GMT</pubDate>
    <dc:creator>OldNick</dc:creator>
    <dc:date>2011-08-01T18:17:19Z</dc:date>
    <item>
      <title>library error with C++ application</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154295#M650</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry if I have already posted this, but I am gettting hopelessly confused...just trying to add a simple C++ file to one of the standard MQX-towerK40 examples (hello.ewp)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;IAR ewarm 6.2, project settings exactly as supplied, with one change - compiler c or c++ "Auto" (based on extension)&lt;/P&gt;&lt;P&gt;C++ version is EEC++&lt;/P&gt;&lt;P&gt;﻿&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#003366"&gt;#include &amp;lt;iostream&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003366"&gt;#include &amp;lt;mqx.h&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003366"&gt;#include &amp;lt;bsp.h&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#003366"&gt;void printstring(void)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003366"&gt;{&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003366"&gt;&amp;nbsp; cout&amp;lt;&amp;lt;"hello"&amp;lt;&amp;lt;endl;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#003366"&gt;}﻿﻿&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The simple act of adding this file to the build (even if you never call printstring() !) causes the linker to warn about there being no heap.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I add the operator overloads to the cpp file in the same way that the PEG++ librar build uses (which DOES work with MQX), the project compiles and links with 0 errors 0 warnings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But the debugger never gets to main.&lt;IMG alt=":robotmad:" class="emoticon emoticon-robotmad" id="robotmad" src="http://freescale.i.lithium.com/i/smilies/16x16_robot-mad.gif" title="Robot Mad" /&gt;&lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;P&gt;Does anybody know what is going on?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS&amp;gt; There are a bunch of similar questions in th ancient history on this forum, but I haven't seen that anybody had it answered yet.&amp;nbsp; It would be nice if there was a FAQ on how to make C++ apps work with MQX, or at least make it clear that it can't be done.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2011 15:58:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154295#M650</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-07-28T15:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: library error with C++ application</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154296#M651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you plase the following in your klinker file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;define block HEAP with size = 0x2000, alignment = 8{ };&lt;/P&gt;&lt;P&gt;place in RAM_region {block HEAP};﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it will work&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jul 2011 15:57:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154296#M651</guid>
      <dc:creator>KJFPE</dc:creator>
      <dc:date>2011-07-29T15:57:07Z</dc:date>
    </item>
    <item>
      <title>Re: library error with C++ application</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154297#M652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;KJFPE wrote:&lt;BR /&gt;&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you plase the following in your klinker file&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;define block HEAP with size = 0x2000, alignment = 8{ };&lt;/P&gt;&lt;P&gt;place in RAM_region {block HEAP};﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it will work&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;it might work, but is it safe?&lt;IMG alt=":robotwink:" class="emoticon emoticon-robotwink" id="robotwink" src="http://freescale.i.lithium.com/i/smilies/16x16_robot-wink.gif" title="Robot wink" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MQX does all its own memory management (I think).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say we need to kill the C++thead due to an RTOS error.&amp;nbsp; What happens to cout if it is on the heap?&amp;nbsp; There is no explicit malloc. for cout...can cout be deleted?&amp;nbsp; Looks like a recipe for a memory leak?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;﻿My belief is that a C++ thread should be able to be written that runs in MQX without having an externally defined heap. &amp;nbsp; I know that this can be done because PEG+ is integrated with MQX and runs (we already discussed this).&amp;nbsp; But PEG+ might not use stdio libraries so might avoid this issue by "accident"?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Since MQX insists on taking over the whole processor, startup code, IO pins, timers, device drivers etc. it would be kind of good to know the limitations of a mixed language environment.﻿&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the more general case, I am simply looking for a way to configure either complier or linker or both which permits C++ application code to run on top of MQX as if MQX were a C++ RTL, but safely.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the fallback position is to abandon C++ altogether and try to write object oriented "C". ( (void *) pthis-&amp;gt;do_stuff(void * paramset )&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works, but is it a good idea?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG alt=":robottongue:" class="emoticon emoticon-robottongue" id="robottongue" src="http://freescale.i.lithium.com/i/smilies/16x16_robot-tongue.gif" title="Robot tongue" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Aug 2011 18:17:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/library-error-with-C-application/m-p/154297#M652</guid>
      <dc:creator>OldNick</dc:creator>
      <dc:date>2011-08-01T18:17:19Z</dc:date>
    </item>
  </channel>
</rss>

