This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

_GNU_SOURCE doesn't enable cuserid() declaration


Linux stdio.h exposes the declaration of cuserid() both with standard
version macros and with _GNU_SOURCE:

tony@mars:~/play$ cat testcuserid.c
#define _GNU_SOURCE
#include <stdio.h>

int main() {
  puts(cuserid(NULL));
  return 0;
}
tony@mars:~/play$ gcc -otestcuserid -Werror=all testcuserid.c
tony@mars:~/play$ ./testcuserid
tony
tony@mars:~/play$ uname -a
Linux mars 4.9.0-8-amd64 #1 SMP Debian 4.9.110-3+deb9u4 (2018-08-21) x86_64 GNU/Linux

while on Cygwin _GNU_SOURCE doesn't expose cuserid():

tony@phobos /cygdrive/n/play
$ gcc -otestcuserid.exe -Werror=all testcuserid.c
testcuserid.c: In function ‘main’:
testcuserid.c:5:8: error: implicit declaration of function ‘cuserid’; did you mean ‘L_cuserid’? [-Werror=implicit-function-declaration]
   puts(cuserid(NULL));
        ^~~~~~~
        L_cuserid
testcuserid.c:5:8: warning: passing argument 1 of ‘puts’ makes pointer from integer without a cast [-Wint-conversion]
In file included from testcuserid.c:2:0:
/usr/include/stdio.h:221:5: note: expected ‘const char *’ but argument is of type ‘int’
 int puts (const char *);
     ^~~~
cc1: some warnings being treated as errors

tony@phobos /cygdrive/n/play
$ uname -a
CYGWIN_NT-6.1 phobos 2.11.2(0.329/5/3) 2018-11-08 14:34 x86_64 Cygwin

This seems unintentional, since L_cuserid is exposed with _GNU_SOURCE
on Cygwin:

tony@phobos /cygdrive/n/play
$ cat testlcuserid.c
#define _GNU_SOURCE
#include <stdio.h>

int main() {
  printf("%d\n", (int)L_cuserid);
  return 0;
}

tony@phobos /cygdrive/n/play
$ gcc -otestlcuserid.exe -Werror=all testlcuserid.c

and on Linux:

tony@mars:~/play$ gcc -otestlcuserid -Werror=all testlcuserid.c

(neither produces a diagnostic)

Tony

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]