Cruz
5th February 2009, 08:54
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));
}
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?
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));
}
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?