I'm just not getting this right somehow. I would like to define a couple of static constants for a class, just like the static final variables in java. This is how I did it:
class SerialCommunication
{
private:
static const qint64 RX_BUFFER_SIZE = 128;
};
void SerialCommunication::receiveMsg()
{
char receiveBuffer[RX_BUFFER_SIZE];
int bytesRead = port->read(receiveBuffer, qMin(port->bytesAvailable(), RX_BUFFER_SIZE));
}
class SerialCommunication
{
private:
static const qint64 RX_BUFFER_SIZE = 128;
};
void SerialCommunication::receiveMsg()
{
char receiveBuffer[RX_BUFFER_SIZE];
int bytesRead = port->read(receiveBuffer, qMin(port->bytesAvailable(), RX_BUFFER_SIZE));
}
To copy to clipboard, switch view to plain text mode
For the second call to RX_BUFFER_SIZE in the read() command I get a compiler error "undefined reference to SerialCommunication::RX_BUFFER_SIZE". How come the first one is ok then? What am I not doing right?
Bookmarks