<?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のトピックC++ OSA Thread Code Design?</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/C-OSA-Thread-Code-Design/m-p/336000#M16024</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the PEx generated code is for C, and not specifically for C++. I have found that when compiling C++ and including the PEx header files, you may get into some challenging compile issues where C++ doesn't allow something that is valid in C. However, even with these challenges, I have workarounds in place that are allowing me to code in C++.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am running the FreeRTOS flavor of OSA, but again, my code is in C++. not C. Because calling C++ from C can be tricky at best, I simply created a C function in the C++ .cpp file and pass a pointer to it when I create my threads. The C function then manipulates data in the class. However, as you can imagine, the C function is not actually part of the class itself, and everything has to be public for it to access it (or getter/setters) and everything defined within the class, such as enums, has be to prefaced with the Class name to access it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Due to the schedule pressure I am under, I really can't take the time to experiment with the best way to implement this, so I have stuck with the C function approach. However, this is actually pretty painful. Therefore, I was wondering if there is a proven pattern folks are using to tackle this particular issue? Calling a member function in the class from the C routine might be one approach, and I do pass the &lt;EM&gt;this&lt;/EM&gt; pointer of the parent class to the thread so it can access its instance's data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks! Happy Coding :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jan 2015 15:34:14 GMT</pubDate>
    <dc:creator>tharonhall</dc:creator>
    <dc:date>2015-01-30T15:34:14Z</dc:date>
    <item>
      <title>C++ OSA Thread Code Design?</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/C-OSA-Thread-Code-Design/m-p/336000#M16024</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So the PEx generated code is for C, and not specifically for C++. I have found that when compiling C++ and including the PEx header files, you may get into some challenging compile issues where C++ doesn't allow something that is valid in C. However, even with these challenges, I have workarounds in place that are allowing me to code in C++.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am running the FreeRTOS flavor of OSA, but again, my code is in C++. not C. Because calling C++ from C can be tricky at best, I simply created a C function in the C++ .cpp file and pass a pointer to it when I create my threads. The C function then manipulates data in the class. However, as you can imagine, the C function is not actually part of the class itself, and everything has to be public for it to access it (or getter/setters) and everything defined within the class, such as enums, has be to prefaced with the Class name to access it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Due to the schedule pressure I am under, I really can't take the time to experiment with the best way to implement this, so I have stuck with the C function approach. However, this is actually pretty painful. Therefore, I was wondering if there is a proven pattern folks are using to tackle this particular issue? Calling a member function in the class from the C routine might be one approach, and I do pass the &lt;EM&gt;this&lt;/EM&gt; pointer of the parent class to the thread so it can access its instance's data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks! Happy Coding :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 15:34:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/C-OSA-Thread-Code-Design/m-p/336000#M16024</guid>
      <dc:creator>tharonhall</dc:creator>
      <dc:date>2015-01-30T15:34:14Z</dc:date>
    </item>
  </channel>
</rss>

