what does the signed/unsigned comparison warning mean?

前端 未结 5 639
南旧
南旧 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:10

    The compiler warns that the code contains comparison of unsigned int with a signed int in the line

    while (numberFound < b);
    

    This has nothing to do with makefiles or make.

    You can fix that by changing

    int b=50;
    

    to

    unsigned b = 50;
    

    or by changing

    unsigned numberFound = 0;
    

    to

    int numberFound = 0;
    

    The problems you might run into when comparing signed int and unsigned int are explained in this answer to another SO question

提交回复
热议问题