Thread: size_t

  1. #1
    Registered User falconetti's Avatar
    Join Date
    Nov 2001
    Posts
    15

    size_t

    Hello,

    Here comes one of those questions that I am always afraid of asking... I have the feeling it is quite a simple one and it almost feels ridiculous, heh. Well ...

    In a prototype declaration, like this one ...

    Code:
    ssize_t read(int fd, void *buf, size_t count);
    where do the the types ssize_t and size_t come from? Are they declared in a library with the enum construct? Why not just declared as int ?

    Well, that was it.

    Thanks in advance !

  2. #2
    Registered User biosx's Avatar
    Join Date
    Aug 2001
    Posts
    230
    It is defined in the stddef.h header. It's an unsigned integer value. That's basically all I know. Maybe this is a start?

  3. #3
    Unregistered
    Guest
    size_t is an unsigned integer type (typedef'd in stddef.h). It's the result type of the sizeof operator, which can be different on different machines. So by using size_t instead of e.g. unsigned int you can write platform independent code. ssize_t is a different thing; it's not in the standard.

Popular pages Recent additions subscribe to a feed