Possible Duplicate:
What does a type followed by _t (underscore-t) represent?
Does anyone knows what the ‘t’ in time_t, uint8_t, etc. stands for, is it “type” ?
second, why declare this kind of new types, for instance size_t, couldn’t it be just an int ?
Yes, the t is for Type.
The reason for defining the new types is so they can change in the future. As 64-bit machines have become the norm, it’s possible for implementations to change the bit-width of
size_tto 64 bits instead of just 32. It’s a way to future-proof your programs. Some small embedded processors only handle 16 bit numbers well. Theirsize_tmight only be 16 bits wide.An especially important one might be
ptrdiff_t, which represents the difference between two pointers. If the pointer size changes (say to 64 or 128 bits) sometime in the future, your program should not care.Another reason for the typedefs is stylistic. While those size_t might just be defined by
using the name
size_tclearly shows that variable is meant to be the size of something (a container, a region of memory, etc, etc).