<?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>S12 / MagniV Microcontrollers中的主题 Re: HCS12 - Const Array of Struct-pointers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183913#M6862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It all makes perfect sense once you realize that you should read from right to left:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TxCommand_Table (is a ) const * (to a) typeTxCMD&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Håkan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Oct 2020 09:34:56 GMT</pubDate>
    <dc:creator>crane</dc:creator>
    <dc:date>2020-10-29T09:34:56Z</dc:date>
    <item>
      <title>HCS12 - Const Array of Struct-pointers</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183910#M6859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello everybody!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm working with a "constant array of pointers to a struct". (Please excuse my english, I'm not sure if that's written allright).&lt;/P&gt;&lt;P&gt;Let's put it into code so you can understand me:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;typedef struct{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte Tx_F;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Tx Flag
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; byte cmd;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Command Number
}typeTxCMD;


typeTxCMD Command_00={0,25};
typeTxCMD Command_01={0,32};
typeTxCMD Command_02={0,44};


const typeTxCMD* TxCommand_Table[]={
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;Command_00,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;Command_01,
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;Command_02
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then, I want to set the Tx Flag of a Command, but that command depends on the value of a variable, let's name it as "var".&lt;/P&gt;&lt;P&gt;So, I do this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TxCommand_Table[var]-&amp;gt;Tx_F = 1;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And when compiling, and error pops up: "&lt;STRONG&gt;C1830: Modifiable lvalue expected&lt;/STRONG&gt;"&lt;/P&gt;&lt;P&gt;To avoid this I did a little "trick" and works fine, but I want to know why it doesn't work the other way.&lt;/P&gt;&lt;P&gt;Here's what I did:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;typeTxCMD* temp;

temp = TxCommand_Table[var];
temp-&amp;gt;Tx_F = 1;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please I hope you guys can give me a hand here.&lt;/P&gt;&lt;P&gt;Best Regards!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:34:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183910#M6859</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2020-10-29T09:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - Const Array of Struct-pointers</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183911#M6860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's actually a pretty common mistake, the problem is that not the array is const, but instead it contains pointers to const elements.&lt;/P&gt;&lt;P&gt;To use a const array with pointers to non const structs move the const after the *:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;typeTxCMD* const TxCommand_Table[...&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:34:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183911#M6860</guid>
      <dc:creator>CompilerGuru</dc:creator>
      <dc:date>2020-10-29T09:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - Const Array of Struct-pointers</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183912#M6861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much!!!!!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 01:13:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183912#M6861</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2011-02-17T01:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - Const Array of Struct-pointers</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183913#M6862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It all makes perfect sense once you realize that you should read from right to left:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;TxCommand_Table (is a ) const * (to a) typeTxCMD&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Håkan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Oct 2020 09:34:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183913#M6862</guid>
      <dc:creator>crane</dc:creator>
      <dc:date>2020-10-29T09:34:56Z</dc:date>
    </item>
    <item>
      <title>Re: HCS12 - Const Array of Struct-pointers</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183914#M6863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for that tip!! It's very useful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Feb 2011 23:50:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/HCS12-Const-Array-of-Struct-pointers/m-p/183914#M6863</guid>
      <dc:creator>sebasira</dc:creator>
      <dc:date>2011-02-17T23:50:30Z</dc:date>
    </item>
  </channel>
</rss>

