Possible Duplicate:
What does a type followed by _t (underscore-t) represent?
I know what the size_t
is. It's an integer type depends on platform. But I cannot figure out what the t
stand for. And there are many typed which suffixes with _t
. What's the _t
means?
"t" means "type" (or to some people, typedef , which is the command used to create them). size_t is the type used to specify memory sizes. time_t on the other hand, is the type used to specify time spans.
size_t is a base unsigned integer memsize-type defined in the standard library of C/C++ languages. This type is described in the header file stddef. h for C and in the file cstddef for C++. Types defined by the header file stddef.
size_t type is a base unsigned integer type of C/C++ language. It is the type of the result returned by sizeof operator. The type's size is chosen so that it can store the maximum size of a theoretically possible array of any type. On a 32-bit system size_t will take 32 bits, on a 64-bit one 64 bits.
The datatype size_t is unsigned integral type. It represents the size of any object in bytes and returned by sizeof operator. It is used for array indexing and counting. It can never be negative. The return type of strcspn, strlen functions is size_t.
"t" means "type" (or to some people, typedef
, which is the command used to create them). size_t
is the type used to specify memory sizes. time_t
on the other hand, is the type used to specify time spans. They generally happen to refer to the same underlying type (a 64-bit or 32-bit integer, depending on the platform), but the label helps keep them straight conceptually so that the implementation details can be hammered out by the compiler.
For example, time_t
used to be a 32-bit integer, meaning that the clock would roll over in 2038. But on most 64-bit architectures, they've expanded time_t
to be a 64-bit integer, which means that 64-bit systems won't have a "year-2038" problem. Since code that deals with unix timestamps uses the type name time_t
rather than int
to refer to these values, everything will "just work" when you simply recompile the code for your new architecture.
In my experience the _t is a conventional suffix for types declared using typedef.
e.g.
typedef int myInt_t;
etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With