Per the C standard, the type of a decimal constant without a suffix is int
, long int
, or long long int
, specifically the first of those that is sufficient to represent the value. In your C implementation, none of those can represent 18446744073709551615, because it is too large.
In order to accommodate you, the compiler is making its type unsigned long
. Technically, this does not conform to the C standard, so the compiler is warning you.
In this case, no harm is caused, because you are assigning the value to an unsigned long
. But there are situations in which using the wrong type can cause problems, so generally you should append a suffix to such constants to ensure they match how they are intended to be used. In this case, a u
is sufficient; as with unsuffixed types, the compiler will decide whether to use unsigned int
, unsigned long int
, or unsigned long long int
depending on the magnitude of the number and the capabilities of the types.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…