本人小白,对一个事情有点不太理解,对于int32这类型的变量,经常可以看到一些项目中在使用,大概了解是为了增强移植性,但是我想知道如果真的是为了移植性的话,那大家以后都不要用int了,都用int32或者int64就好了啊,为什么不这样呢?int存在的必要是什么呢?当然不单指int,意思是所有类似的,比如uint
黄舟2017-04-17 14:58:56
int8_t int16_t
requires stdint.h, int
is native.
If some platforms (such as microcontrollers) do not have a stdint library, you can only use int
PHP中文网2017-04-17 14:58:56
int32_t was only introduced in C99. Indeed, it is often recommended to use int32_t instead of int, but usually only module export interfaces, network programming, and embedded programming have requirements for integer length. In other cases, there are no requirements. You can use int to keep the code simple, int is generally It is the type that can guarantee the fastest CPU speed. In particular, it is recommended to use uint8_t instead for unsigned char.
高洛峰2017-04-17 14:58:56
I don’t think there is much need to worry about abandoning int or not. Language provides the elements and norms for our use. It doesn't mean it's useless if you don't use it. If you don’t use it now, you may use it in the future. If you don’t use it, someone else may use it. If all ints are canceled now, how to maintain the previous software written with ints?