I've got a little problem with pointers and references.
Here the definition of some structure that I use:
struct PortConfiguration
{
PinConfiguration port0[8]; //!< Configuration of the port 0
PinConfiguration port1[8]; //!< Configuration of the port 1
bool valid; //!< Flag: queryPinIOConfiguration() succeeds
};
struct PinConfiguration
{
PinUserMode userIO; //!< Specify if a pin can be used by the user or if it used internaly by the module
PinResistorType pullUpDownType; //!< Specify if the input pin use a pull-up or pull-down resistor
PinResistorState pullUpDownState; //!< Specify if the pull-up/pull-down resistor is used or not
PinDigitalIO digitalDir; //!< Specify the direction of a digital pin
PinDigitalLevel outputValue; //!< Specify the digital level of a digital pin
PinDigitalState digitalState; //!< Specify if a pin is a digital or analog pin
};
struct PortConfiguration
{
PinConfiguration port0[8]; //!< Configuration of the port 0
PinConfiguration port1[8]; //!< Configuration of the port 1
bool valid; //!< Flag: queryPinIOConfiguration() succeeds
};
struct PinConfiguration
{
PinUserMode userIO; //!< Specify if a pin can be used by the user or if it used internaly by the module
PinResistorType pullUpDownType; //!< Specify if the input pin use a pull-up or pull-down resistor
PinResistorState pullUpDownState; //!< Specify if the pull-up/pull-down resistor is used or not
PinDigitalIO digitalDir; //!< Specify the direction of a digital pin
PinDigitalLevel outputValue; //!< Specify the digital level of a digital pin
PinDigitalState digitalState; //!< Specify if a pin is a digital or analog pin
};
To copy to clipboard, switch view to plain text mode
This structures are defined in the class MatrixModule.
Now, in the code of some function I want to create an array of pointers of the 2 ports: port0 and port1, so it will be easy to use in loop.
void IOPortConfig::setConfig(const MatrixModule::PortConfiguration &config)
{
const MatrixModule::PinConfiguration* ports[2][8];
ports[0] = &(config.port0);
ports[1] = &(config.port1);
void IOPortConfig::setConfig(const MatrixModule::PortConfiguration &config)
{
const MatrixModule::PinConfiguration* ports[2][8];
ports[0] = &(config.port0);
ports[1] = &(config.port1);
To copy to clipboard, switch view to plain text mode
In this way doesn't work:
error: incompatible types in assignment of ‘const MatrixModule::PinConfiguration (*)[8]’ to ‘const MatrixModule::PinConfiguration* [8]’
How should I do?
Bookmarks