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

Bug#728240: libc6: S_IFMT constants not included when _POSIX_C_SOURCE is defined as 200112L



reassign 728240 manpages-dev
retitle 728240 manpages-dev: stat(2): S_IF* constants are part of the XSI extension
thanks

On Tue, Oct 29, 2013 at 08:39:23PM +0000, Richard Ipsum wrote:
> Package: libc6
> Version: 2.17-93
> Severity: normal
> 
> The man page for stat states
> 
> POSIX.1-1990 did not describe the S_IFMT, S_IFSOCK, S_IFLNK,
> S_IFREG, S_IFBLK,
> S_IFDIR, S_IFCHR, S_IFIFO, S_ISVTX constants, but instead demanded
> the use of the
> macros S_ISDIR(), etc.

Correct.

> The S_IF* constants are present in
> POSIX.1-2001 and later.

That's not fully correct. The S_IF* constants indeed appeared in
POSIX.1-2001, but as part of the XSI extension.

> However, when I write the following program:
> 
> #define _POSIX_C_SOURCE 200112L

You need to define _XOPEN_SOURCE to enable the XSI extension, and with
it the S_IFMT constant.

> #include <sys/stat.h>
> #include <stdio.h>
> 
> int main(void)
> {
> printf("%d\n", S_IFMT);
> return 0;
> }
> 
> and compile
> 
> [camomile:~]% gcc -o foo foo.c
> foo.c: In function ‘main’:
> foo.c:9:17: error: ‘S_IFMT’ undeclared (first use in this function)
> printf("%d\n", S_IFMT);
> ^
> foo.c:9:17: note: each undeclared identifier is reported only once
> for each function it appears in

It compiles fine with -D_XOPEN_SOURCE.

It looks like the manpage is not clear, so I am reassigning the bug to
manpages-dev.

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net


Reply to: