今天看到size_t,查了一下wiki,解释如下:
- From Wikipedia, the free encyclopedia
- size_t is an unsigned data type defined by several C/C++ standards (e.g., the C99 ISO/IEC 9899 standard) that is defined in stddef.h.[1] It can be further imported by inclusion of stdlib.h as this file internally sub includes stddef.h.[2]
- This type is used to represent the size of an object. Library functions that take or return sizes expect them to be of type or have the return type ofsize_t. Further, the most frequently used compiler-based operator sizeof should evaluate to a value that is compatible with size_t.
- [edit]Range and storage size of size_t
- The actual type of size_t is platform-dependent; a common mistake is to assume size_t is the same as unsigned int, which can lead to programming errors,[3][4] when moving from 32 to 64-bit architecture, for example.
- According to the 1999 ISO C standard (C99), size_t is an unsigned integer type of at least 16 bits.
- [edit]Signed variant ssize_t
- In some implementations there is further a non-standard signed variant of this type with name ssize_t. The type definition for ssize_t is available in most Unix compatible systems. It was probably introduced by the second edition of the POSIX 1003.1 standard (1003.1-1996).[5]
- The ssize_t type follows the same rules as size_t for its storage size, location and inclusion, and uses the implementation's usual representation of signed values—2's complement in most, if not all, cases.
阅读(1202) | 评论(0) | 转发(0) |