<?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 C++ class variables are not initialized in S32 Design Studio</title>
    <link>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836732#M3980</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing weird problem with C++.&lt;/P&gt;&lt;P&gt;With the below example,&amp;nbsp;the print message supposed to be 'Value=22'. But I am seeing it as 'Value=1".&lt;/P&gt;&lt;P&gt;May I know the reason for it please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI, I am using S32DS for ARM C++ Application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Hari&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "S32K148.h" /* include peripheral declarations S32K148 */&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/P&gt;&lt;P&gt;class MyClass&lt;BR /&gt;{&lt;BR /&gt;public:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;int a=10;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;MyClass()&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a += 11;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyClass myClass;&lt;/P&gt;&lt;P&gt;void func1(void)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;int x = ++myClass.a;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Value=%d",x);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;func1();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;while(1);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 29 Jun 2018 23:49:51 GMT</pubDate>
    <dc:creator>__invited__hari</dc:creator>
    <dc:date>2018-06-29T23:49:51Z</dc:date>
    <item>
      <title>C++ class variables are not initialized</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836732#M3980</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing weird problem with C++.&lt;/P&gt;&lt;P&gt;With the below example,&amp;nbsp;the print message supposed to be 'Value=22'. But I am seeing it as 'Value=1".&lt;/P&gt;&lt;P&gt;May I know the reason for it please?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FYI, I am using S32DS for ARM C++ Application.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Hari&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#include "S32K148.h" /* include peripheral declarations S32K148 */&lt;BR /&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/P&gt;&lt;P&gt;class MyClass&lt;BR /&gt;{&lt;BR /&gt;public:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;int a=10;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;MyClass()&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;a += 11;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MyClass myClass;&lt;/P&gt;&lt;P&gt;void func1(void)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;int x = ++myClass.a;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;printf("Value=%d",x);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main()&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;func1();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;while(1);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 29 Jun 2018 23:49:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836732#M3980</guid>
      <dc:creator>__invited__hari</dc:creator>
      <dc:date>2018-06-29T23:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: C++ class variables are not initialized</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836733#M3981</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;&lt;/P&gt;&lt;P&gt;it looks like that there is bug in startup file - thanks for report. You can fix it by adding&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bl _start&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;instead&lt;/P&gt;&lt;P&gt;bl main&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;in the startupS32K148.S file:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/64687i338CF6C3212BD6F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jiri&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2018 14:47:10 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836733#M3981</guid>
      <dc:creator>jiri_kral</dc:creator>
      <dc:date>2018-07-02T14:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: C++ class variables are not initialized</title>
      <link>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836734#M3982</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jiri.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That works. Appreciated your quick turnaround.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Hari&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2018 16:16:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32-Design-Studio/C-class-variables-are-not-initialized/m-p/836734#M3982</guid>
      <dc:creator>__invited__hari</dc:creator>
      <dc:date>2018-07-02T16:16:11Z</dc:date>
    </item>
  </channel>
</rss>

