Bug 11125 - <stdio.h> is incomplete for POSIX 2008
Summary: <stdio.h> is incomplete for POSIX 2008
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.11
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-01-01 23:08 UTC by Eric Blake
Modified: 2014-06-30 20:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Blake 2010-01-01 23:08:39 UTC
POSIX 2008 requires that <stdio.h> expose ssize_t, va_list, and getline (among
others) if _POSIX_C_SOURCE is 200809L or greater.  However, this valid POSIX
2008 program fails to compile with glibc:

$ cat file.c
#define _POSIX_C_SOURCE 200809L
#include <stdio.h>
int main ()
{
  ssize_t s;
  va_list v;
  char *p = NULL;
  size_t s1 = 0;
  return getline (&p, &s1, stdin);
}
$ gcc -o file -Wall file.c
file.c: In function 'main':
file.c:5: error: 'ssize_t' undeclared (first use in this function)
file.c:5: error: (Each undeclared identifier is reported only once
file.c:5: error: for each function it appears in.)
file.c:5: error: expected ';' before 's'
file.c:6: error: 'va_list' undeclared (first use in this function)
file.c:6: error: expected ';' before 'v'
file.c:9: warning: implicit declaration of function 'getline'
$
Comment 1 Jakub Jelinek 2010-01-04 21:02:56 UTC
Can't reproduce the getline issue, it is prototyped (since 2009-02-26).
va_list is defined only with -D_XOPEN_SOURCE=700, not with
-D_POSIX_C_SOURCE=200809L, not sure what is right.  If it is supposed to be
defined also for _POSIX_C_SOURCE >= 200909L, then
#ifdef __USE_XOPEN
# ifdef __GNUC__
#  ifndef _VA_LIST_DEFINED
typedef _G_va_list va_list;
#   define _VA_LIST_DEFINED
#  endif
# else
#  include <stdarg.h>
# endif
#endif
would need to use #if defined __USE_XOPEN || defined __USE_XOPEN2K8
instead (or __USE_XOPEN2K?).

ssize_t would need something like:
#ifdef __USE_XOPEN2K8
# ifndef __ssize_t_defined
typedef __ssize_t ssize_t;
#  define __ssize_t_defined
# endif
#endif
in a right spot in libio/stdio.h.
Comment 2 Ulrich Drepper 2010-01-10 08:40:17 UTC
Fixed in git.