comparison between signed and unsigned integer expression s [-Werror=sign-compare]

在这里插入图片描述
ret[i].Id 是unsigned int 型,min_index是int,不能直接比较

但将min_index直接定义为unsigned 类型,-1是有符号的,在min_index == -1又是同样的错误,因此直接将比较中的-1也强制转为unsigned类型,如下图
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_29230349/article/details/104536360