Re: Pointers and references
remove the "*" in
Code:
/*const*/ MatrixModule::PinConfiguration/***/ ports[2][8];
EDIT:
and also remove the "const"
Re: Pointers and references
Why I should remove the *? I don't want to copy all the structure, I just want a pointer.
Anyway, I've tried your code (I also remove the const in the function), now the error is:
error: incompatible types in assignment of ‘MatrixModule::PinConfiguration (*)[8]’ to ‘MatrixModule::PinConfiguration [8]’
Code:
void IOPortConfig::setConfig(MatrixModule::PortConfiguration &config)
{
MatrixModule::PinConfiguration ports[2][8];
ports[0] = &(config.port0);
ports[1] = &(config.port1);
Re: Pointers and references
Quote:
Originally Posted by
PaceyIV
Why I should remove the *? I don't want to copy all the structure, I just want a pointer.
edit: my mistake... do it like below
Quote:
Anyway, I've tried your code (I also remove the const in the function), now the error is:
error: incompatible types in assignment of ‘MatrixModule::PinConfiguration (*)[8]’ to ‘MatrixModule::PinConfiguration [8]’
remove the [8]
Code:
void IOPortConfig::setConfig(MatrixModule::PortConfiguration &config)
{
MatrixModule::PinConfiguration *ports[2]/*[8]*/;//now keep the *
ports[0] = &(config.port0);
ports[1] = &(config.port1);
Re: Pointers and references
hope now it works... i have edited the above post :)
Re: Pointers and references
I had already tried your suggestion. I had added [8] for this error message:
error: cannot convert ‘MatrixModule::PinConfiguration (*)[8]’ to ‘MatrixModule::PinConfiguration*’ in assignment
Re: Pointers and references
you have to remove the [8] and bring back the *... take a look at the post again..
Re: Pointers and references
Code:
//! Set the widget values from the PinConfiguration structure provided
void IOPortConfig::setConfig(MatrixModule::PortConfiguration &config)
{
MatrixModule::PinConfiguration *ports[2];
ports[0] = &(config.port0);
ports[1] = &(config.port1);
error: cannot convert ‘MatrixModule::PinConfiguration (*)[8]’ to ‘MatrixModule::PinConfiguration*’ in assignment
Re: Pointers and references
oh.. man... i should have read your first post carefully... my mistake my mistake.. sorry.. give me a minute..
EDIT : ... remove the & now.
Code:
port[1] = /*&*/config.port;
Re: Pointers and references
hope it works now :)
EDIT: i was all the time confusing Port and Pin as same Configuration :)
Re: Pointers and references
It works! Good.
Yes, sure! config.port is a pointers to config.port[0]. I should have used the & with config.port[0].
Now I can also re-add the const.
Thanks!