AnsweredAssumed Answered

HCS12 - Const Array of Struct-pointers

Question asked by sebasira on Feb 16, 2011
Latest reply on Feb 17, 2011 by sebasira

Hello everybody!


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).

Let's put it into code so you can understand me:



typedef struct{
      byte Tx_F;      // Tx Flag
      byte cmd;       // Command Number

typeTxCMD Command_00={0,25};
typeTxCMD Command_01={0,32};
typeTxCMD Command_02={0,44};

const typeTxCMD* TxCommand_Table[]={


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".

So, I do this:



TxCommand_Table[var]->Tx_F = 1;


And when compiling, and error pops up: "C1830: Modifiable lvalue expected"

To avoid this I did a little "trick" and works fine, but I want to know why it doesn't work the other way.

Here's what I did:



typeTxCMD* temp;

temp = TxCommand_Table[var];
temp->Tx_F = 1;


Please I hope you guys can give me a hand here.

Best Regards!