This question already has an answer here:
- Determine array size in constructor initializer 11 answers
I am creating a class to handle some radio-communication between two radios each connected to an Arduino. I was planning on having a list of functions passed to the class to handle different messages that are received.
My problem is that upon saving an array of functions to a private variable I get the following error:
incompatible types in assignment of 'void (**)(uint8_t*) {aka void (**)(unsigned char*)}' to 'void (* [0])(uint8_t*) {aka void (* [0])(unsigned char*)}'
The only difference being *
vs a [0]
Comms.h
class Comms {
public:
//data handlers are arrays of functions that handle data received with an id equal to their index in the array
typedef void (*DataHandler)(uint8_t data[RH_RF95_MAX_MESSAGE_LEN]);
Comms(bool isMaster, uint16_t Hz, DataHandler handlers[]);
void updateRun();
//first element should be the id, followed by some data
void queueData(uint8_t data[RH_RF95_MAX_MESSAGE_LEN]);
int8_t getLastRSSI();
private:
RH_RF95 *rf95;
QueueList<uint8_t[]> messageQueue;
bool master;
uint16_t pingDelay;
DataHandler dataHandlers[];
};
Comms.cpp trimmed down
#include "Comms.h"
Comms::Comms(bool isMaster, uint16_t hz, DataHandler handlers[]){
master = isMaster;
pingDelay = 1/hz;
dataHandlers = handlers; ######ERROR HERE######
////setup code////
...