what does the signed/unsigned comparison warning mean?

前端 未结 5 439
南旧
南旧 2021-01-29 06:42
auto.cpp: In function ‘int autooo(unsigned int)’:
auto.cpp:33:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

5条回答
  •  醉梦人生
    2021-01-29 07:06

    At this line

    while (numberFound < b);

    The first is an unsigned int and the second an int. So you have to make them the same type, or if you are completely sure cast one of them.

    As Etan commented:

    "Blindly casting away a warning just to avoid the warning is a mistake. You need to understand what the warning is telling you and decide what the right fix is."

提交回复
热议问题