Re: Why does stat(2) say <unistd.h> is needed?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/9/21 12:53 PM, Jonathan Wakely wrote:
> On 09/02/21 12:27 +0100, Alejandro Colomar (man-pages) wrote:
>> Hello Jonathan,
>>
>> On 2/9/21 12:09 PM, Jonathan Wakely wrote:
>>> The stat(2) man page says:
>>>
>>> SYNOPSIS
>>>        #include <sys/types.h>
>>>        #include <sys/stat.h>
>>>        #include <unistd.h>
>>>
>>>        int stat(const char *pathname, struct stat *statbuf);
>>>        int fstat(int fd, struct stat *statbuf);
>>>        int lstat(const char *pathname, struct stat *statbuf);
>>>
>>> But I don't see anything there that would require <unistd.h>. POSIX
>>> doesn't require it (and since POSIX.1-2001 no longer requires
>>> <sys/types.h>, saying "Although <sys/types.h> was required for
>>> conforming implementations of previous POSIX specifications, it was
>>> not required for UNIX applications.")
>>>
>>> Is the inclusion of <unistd.h> there a mistake?
>>>
>>> I've been trying to track down why a libstdc++ header includes
>>> <unistd.h> for no apparent reason, and my best guess is that it's a
>>> result of this man page saying to do it.
>>>
>> As far as we can tell, there's no reason to include it.  See
>> <https://lore.kernel.org/linux-man/97457bf2-2b29-af4b-c910-2391c69c4134@xxxxxxxxx/>.
>>
>>
>> We haven't fixed it yet, because I'd like to fix all of the pages, and
>> that's likely to take months (reading through every manual page in
>> senctions 2 & 3, reading thorugh every included header, checking POSIX
>> requirements, asking Michael if there may be historical reasons for a
>> specific case, ...), but I'll do it some day.
>>
>> For now, if you submit a patch, I'll merge it.
> 
> Attached, thanks.
> 
> 

Hi Jonathan,

Patch applied!

However, we normally prefer inline patches, if possible.

Thanks,

Alex

-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
http://www.alejandro-colomar.es/



[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux