Description of problem: The man page of getlogin(3) says that L_cuserid is declared in <stdio.h>. But if I try to compile (gcc-4.7.0-5.fc17.x86_64) a little source using L_cuserid #include <unistd.h> #include <stdio.h> main () { fprintf (stderr,"L_cuserid = %d",L_cuserid); } I get an error: x.c: In function ‘main’: x.c:4:34: error: ‘L_cuserid’ undeclared (first use in this function) x.c:4:34: note: each undeclared identifier is reported only once for each function it appears in The source compiles correctly if I use -D_XOPEN_SOURCE or -D_GNU_SOURCE Version-Release number of selected component (if applicable): glibc-headers-2.15-51.fc17.x86_64 How reproducible: always Steps to Reproduce: 1.compile the above source 2. 3. Actual results: syntax error Expected results: compiles without any additional defines (such as the manpage says) Additional info: Installed on my box: glibc-devel-2.15-51.fc17.x86_64 glibc-2.15-51.fc17.x86_64 glibc-2.15-51.fc17.i686 glibc-common-2.15-51.fc17.x86_64 glibc-headers-2.15-51.fc17.x86_64 glibc-devel-2.15-51.fc17.i686 gcc-java-4.7.0-5.fc17.x86_64 gcc-4.7.0-5.fc17.x86_64 gcc-c++-4.7.0-5.fc17.x86_64
The cuserid interfaces are documented as needing feature test macros in the man page: Feature Test Macro Requirements for glibc (see feature_test_macros(7)): getlogin_r(): _REENTRANT || _POSIX_C_SOURCE >= 199506L cuserid(): _XOPEN_SOURCE ie, it is expected that you need to define _XOPEN_SOURCE to use cuserid/L_cuserid.