sizeof() return type ?

Ian Lance Taylor iant@google.com
Thu Jun 22 20:07:00 GMT 2006


Darryl Miles <darryl-mailinglists@netbauds.net> writes:

> This one is taxing me, what is the correct type returned by the built
> in sizeof() operator ?
> 
> int ?
> unsigned int ?
> size_t ?
> ssize_t ?

This is a general C question, not a gcc question.  As such, it should
probably go to a mailing list about C, not to a mailing list
specifically about gcc.  Thanks.

The answer is that sizeof returns a value of type size_t.

> Where does size_t and ssize_t originate from ?  ANSI/stdio ?

I believe size_t was introduced in the ISO C90 standard.  I believe
that ssize_t was introduced in the second edition of the POSIX 1003.1
standard (1003.1-1996).

Ian



More information about the Gcc-help mailing list