warning: comparison of unsigned expression >= 0 is always true

前端 未结 5 1247
野性不改
野性不改 2020-12-11 23:23

I have the following error when compiling a C file:

t_memmove.c: In function ‘ft_memmove’:
ft_memmove.c:19: warning: comparison of unsigned expression >=          


        
5条回答
  •  孤城傲影
    2020-12-11 23:47

    If you subtract two unsigned integers in C, the result will be interpreted as unsigned. It doesn't automatically treat it as signed just because you subtracted. One way to fix that is use n >= i instead of n - i >= 0.

提交回复
热议问题