c++ - 关于c语言中的变量
巴扎黑
巴扎黑 2017-04-17 14:56:56
0
3
502

本人小白,对一个事情有点不太理解,对于int32这类型的变量,经常可以看到一些项目中在使用,大概了解是为了增强移植性,但是我想知道如果真的是为了移植性的话,那大家以后都不要用int了,都用int32或者int64就好了啊,为什么不这样呢?int存在的必要是什么呢?当然不单指int,意思是所有类似的,比如uint

巴扎黑
巴扎黑

reply all(3)
黄舟

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

洪涛

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.

小葫芦

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?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!