我在代码中有这样的表达式:
QByteArray idx0 = ...
unsigned short ushortIdx0;
if ( idx0.size() >= sizeof(ushortIdx0) ) {
// Do something
}
但是我收到了警告:
warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if ( idx0.size() >= sizeof(ushortIdx0) ) { ~~~~~~~~~~~~^~~~~~~~~~
为什么QByteArray
的size()
返回值是int
而不是unsigned int
?我该如何安全地消除这个警告?