Hi guys,
I'm having trouble to understand why I get an error when I define a cppQueue member in a class.
I get the error
src\CommMgr.h:60:32: error: expected identifier before 'sizeof'
cppQueue payloadsQueue(sizeof(Publication), QUEUE_MAX_LENGTH, FIFO);
Why is sizeof unexpected?
Here's the problematic code
////////////////////////////////////////////////////////////////////////////////
// Data types
////////////////////////////////////////////////////////////////////////////////
struct Publication {
char topic [TOPIC_MAX_LENGTH];
char payload [PAYLOAD_MAX_LENGTH];
};
class CommMgr {
public :
CommMgr(Reseau &reseau);
CommMgr(char * ipAddr);
void Init();
void Task();
void PublishData(const char *topic, const char * payload);
void PushPayload(const char *topic, const char * payload);
void TestPublish();
private:
bool isInitialized = false;
char moduleName[NAME_SIZE]; ///< Name of the device
char * mqttServerIP;
int mqttServerPort = 1883;
PubSubClient mqttClient;
EthernetClient ethClient;
Reseau ethernet;
char rootTopic[TOPIC_ROOT_LENGTH] = "BIOREACTOR";
cppQueue payloadsQueue(sizeof(Publication), QUEUE_MAX_LENGTH, FIFO); /// ERROR HERE!!
unsigned long currentTime;
unsigned long lastTest = 0;
unsigned int testRate = 2000;
};
#endif
if I do the same thing in a basic class, I get no error.
#include "cppQueue.h"
class TestClass {
public:
cppQueue q(sizeof(String *));
}
Why??