Tony Cook
2018-11-29 02:22:42 UTC
Linux stdio.h exposes the declaration of cuserid() both with standard
version macros and with _GNU_SOURCE:
***@mars:~/play$ cat testcuserid.c
#define _GNU_SOURCE
#include <stdio.h>
int main() {
puts(cuserid(NULL));
return 0;
}
***@mars:~/play$ gcc -otestcuserid -Werror=all testcuserid.c
***@mars:~/play$ ./testcuserid
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():
***@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
***@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:
***@phobos /cygdrive/n/play
$ cat testlcuserid.c
#define _GNU_SOURCE
#include <stdio.h>
int main() {
printf("%d\n", (int)L_cuserid);
return 0;
}
***@phobos /cygdrive/n/play
$ gcc -otestlcuserid.exe -Werror=all testlcuserid.c
and on Linux:
***@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
version macros and with _GNU_SOURCE:
***@mars:~/play$ cat testcuserid.c
#define _GNU_SOURCE
#include <stdio.h>
int main() {
puts(cuserid(NULL));
return 0;
}
***@mars:~/play$ gcc -otestcuserid -Werror=all testcuserid.c
***@mars:~/play$ ./testcuserid
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():
***@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
***@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:
***@phobos /cygdrive/n/play
$ cat testlcuserid.c
#define _GNU_SOURCE
#include <stdio.h>
int main() {
printf("%d\n", (int)L_cuserid);
return 0;
}
***@phobos /cygdrive/n/play
$ gcc -otestlcuserid.exe -Werror=all testlcuserid.c
and on Linux:
***@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