Why is st_size defined as a signed int?

Andrew Bell andrew.bell.ia@gmail.com
Tue Apr 27 17:05:45 GMT 2021


On Tue, Apr 27, 2021 at 12:46 PM Peng Yu via Libc-help <
libc-help@sourceware.org> wrote:

> Hi,
>
> https://github.com/bminor/glibc/blob/master/bits/stat.h#L47
>
> I see st_size is defined as __off_t, which should be a signed int. But
> can a file size be negative. If not, why not use an unsigned int to
> represent the file size?


This is required by the POSIX standard.

-- 
Andrew Bell
andrew.bell.ia@gmail.com


More information about the Libc-help mailing list