<?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>Kinetis MicrocontrollersのトピックRe: &amp;quot;new&amp;quot; in C++ does not create code on the heap</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241375#M5972</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The pointer *flash was created on the heap, but it points to the original code in flash memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try creating that RAM copy myself to see how/if it works for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 06 Aug 2013 13:13:44 GMT</pubDate>
    <dc:creator>donden</dc:creator>
    <dc:date>2013-08-06T13:13:44Z</dc:date>
    <item>
      <title>"new" in C++ does not create code on the heap</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241373#M5970</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a C++ project in Codewarrior 10.3 targeting Kinetis K61FN1M0VMJ12.&amp;nbsp; I am attempting to do a Bootloader that will reprogram Flash in the field.&amp;nbsp; I need to instantiate my Flash class in RAM so it can perform flash erase and write operations.&amp;nbsp; However, using "new" only creates a RAM pointer to the flash-based code.&amp;nbsp; How can I get the class (about 1200 bytes long) onto the heap?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using "new" in C++ with the intent of creating a copy of a class on the heap. The location on the heap is necessary for hardware reasons in writing to Flash memory.&amp;nbsp; I am using:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;static Watchdog *wd;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;Flash&amp;nbsp;&amp;nbsp;&amp;nbsp; *flash;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;wd = new(std::nothrow) Watchdog;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Courier New';"&gt;flash = new(std::nothrow) Flash();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is that the only thing that ends up in RAM is the pointer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using gnu C++ compiler chain on eclipse for Codewarrior.&amp;nbsp; Does anyone know of a compiler directive that is causing the problem, or that would actually create an instance on the stack?&amp;nbsp; All the manuals I have indicate that “new” should instantiate the object on the heap.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BTW, Watchdog *wd is used by&amp;nbsp; various functions in the main.cpp file.&amp;nbsp; Flash *flash is used in two or three files that need special access to Flash registers in the processor.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Don DenTandt&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Aug 2013 21:39:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241373#M5970</guid>
      <dc:creator>donden</dc:creator>
      <dc:date>2013-08-05T21:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: "new" in C++ does not create code on the heap</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241374#M5971</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1. The pointer flash pointed to heap after the newing?&lt;/P&gt;&lt;P&gt;2. It is expected that the new will malloc mem for the class on heap and then call the class's construct function. And it will not "&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12.727272033691406px;"&gt;creating a copy of a class on the heap&lt;/SPAN&gt;" unless you do it in the construct function&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 03:06:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241374#M5971</guid>
      <dc:creator>JerryFan</dc:creator>
      <dc:date>2013-08-06T03:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: "new" in C++ does not create code on the heap</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241375#M5972</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The pointer *flash was created on the heap, but it points to the original code in flash memory.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I will try creating that RAM copy myself to see how/if it works for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Aug 2013 13:13:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/quot-new-quot-in-C-does-not-create-code-on-the-heap/m-p/241375#M5972</guid>
      <dc:creator>donden</dc:creator>
      <dc:date>2013-08-06T13:13:44Z</dc:date>
    </item>
  </channel>
</rss>

