我有以下Qt
代码块:
if(this->ueCommunicationsSocket()->bind(QHostAddress(data[0].toString()),
static_cast<quint16>(data[1].toInt())),
QAbstractSocket::ShareAddress)
{
qDebug() << Q_FUNC_INFO
<< "TCP socket bind succesfull";
}
else
{
qDebug() << Q_FUNC_INFO
<< QString::number(this->ueCommunicationsSocket()->error())
<< this->ueCommunicationsSocket()->errorString(); // here i get semantic issue
} // if
答案 0 :(得分:2)
if(this->ueCommunicationsSocket()->bind(QHostAddress(data[0].toString()),
static_cast<quint16>(data[1].toInt())),
QAbstractSocket::ShareAddress)
是
if ( /*something */, QAbstractSocket::ShareAddress)
由于AbstractSocket::SharedAddress
为0x1
,因此带有逗号运算符!
的条件始终为真,即永远不会执行else
分支。