Can't get rid of “this decimal constant is unsigned only in ISO C90” warning

后端 未结 1 1033
一向
一向 2020-12-13 09:15

I\'m using the FNV hash as a hashing algorithm on my Hash Table implementation but I\'m getting the warning in the question title on this line:

unsigned hash         


        
相关标签:
1条回答
  • 2020-12-13 09:56
    unsigned hash = 2166136261u; // note the u.
    

    You need a suffix u to signify this is an unsigned number. Without the u suffix it will be a signed number. Since

    2166136261 > 2³¹ - 1 = INT_MAX,
    

    this integer literal will be problematic.

    0 讨论(0)
提交回复
热议问题