QtCreator语义问题警告代码永远不会执行 [英] QtCreator semantic issue warning code will never be executed
本文介绍了QtCreator语义问题警告代码永远不会执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下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
我收到语义问题警告代码将永远不会执行。我知道这是个愚蠢的错误,我已经准备好投反对票了,但是,我找不到错误!这里还有一张截图:
推荐答案
if(this->ueCommunicationsSocket()->bind(QHostAddress(data[0].toString()),
static_cast<quint16>(data[1].toInt())),
QAbstractSocket::ShareAddress)
是
if ( /*something */, QAbstractSocket::ShareAddress)
由于AbstractSocket::SharedAddress
为0x1
,!
这个带有逗号运算符的条件始终为真,即else
分支永远不会执行。
这篇关于QtCreator语义问题警告代码永远不会执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文