Size of data types does vary depending upon OS or platform? [duplicate]
Possible Duplicate:
size of a datatype in c
I want to ask you does size of any data types does vary on different os or platform.? like 32-bit system 64 bit system.?
Question is more for c langu开发者_如何转开发age programming.They can yes (and they often do). The C standard requires certain minimal ranges for integer and floating point types, but leaves a lot of freedom to the platform to decide the actual sizes of the types.
See eg. limits.h
and float.h
.
Furthermore, there is a strict relation between the sizes of integer types that needs to be true :
sizeof(char) == 1
sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)
Platforms will usually pick sizes that are natural to the hardware. For example, int
s will usually have the native word size (32 bits on 32bit hardware eg.).
For floating point types, there is less variation. Most platforms are more or less compliant with IEEE 754.
Sure. This is implicit in your question on a 32 bit system pointers are 32 bit that is usually 4 byte, on 64bit system 8 byte.
精彩评论