Short Size

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Short Size

1,182 次查看
carlosmscabral
Contributor I
Hello there,

Using the compiler option 4-byte integer, a short will have, always, 2 bytes?

I can't understand exactaly the definitions of uint32, uint16... and how the compiler handles them.

Thanks
标签 (1)
0 项奖励
2 回复数

295 次查看
admin
Specialist II
> Using the compiler option 4-byte integer, a short will have, always, 2 bytes?
No, this is an architecture dependent.
But, sizeof(short int) is 2 bytes for all known to me 32-bit architectures.
 
> I can't understand exactly the definitions of uint32, uint16... and how the compiler handles them.
Regularly, UINT32 has the range from 0 to 2^31-1.
Regularly, UINT16 has the range from 0 to 2^15-1.
 
0 项奖励

295 次查看
JimDon
Senior Contributor III

The purpose of uint32, uint16 etc. is that they are adjusted for the environment you are in so that they are always that size regardless.

So if you use uint32, and you change compilers, processor, or compile options these are adjustedt in one place, vs all over if you use unsigned int.

0 项奖励