"William Xuuu" <> wrote in message
news:...
> This's a way of defining size_t and ssize_t in Linux:
>
> //"linux/types.h"
> typedef __kernel_size_t size_t;
> typedef __kernel_ssize_t ssize_t;
>
> //"asm/posix_types.h"
> typedef unsigned int __kernel_size_t;
> typedef int __kernel_ssize_t;
>
> It seems so tricky to me. What benefits do we get from such a tricky
> typedef ? better name (size_t is shorter than unsigned int) ?
On some 64-bit platforms, 'int' and 'unsigned int' may be 32-bits,
while addresses and even memory sizes could require 64 bits
(e.g. for the size of an allocated memory block > 4GB).
On such platforms, size_t could be typedef'd to a different
type, such as 'unsigned long long'.
Note also that 'size_t' is a typedef required by the ISO C standard
(it must be available if <stddef.h> is included). However, 'ssize_t'
does not exist in the C standard -- the standard 'ptrdiff_t'
typedef is nearly equivalent.
hth,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form