Declaration of crypt
Corinna Vinschen
corinna-cygwin@cygwin.com
Thu Jun 9 09:00:00 GMT 2016
Hi Ken,
On Jun 8 17:18, Ken Brown wrote:
> According to Posix, including <unistd.h> should bring in the declaration of
> crypt. The glibc and FreeBSD headers are consistent with this, but Cygwin's
> aren't.
>
> $ cat test.c
> #include <unistd.h>
>
> int
> main (void)
> {
> const char *key = NULL;
> const char *salt = NULL;
> crypt (key, salt);
> }
>
> $ gcc -c test.c
> test.c: In function ‘main’:
> test.c:8:3: warning: implicit declaration of function ‘crypt’
> [-Wimplicit-function-declaration]
> crypt (key, salt);
> ^
>
> The attached patch is one way to fix this. It means that cygwin-devel would
> have to require libcrypt-devel.
>
> I'm not sure if I used the right feature-test macro in the patch. It's
> marked XSI by Posix, but using __XSI_VISIBLE didn't work.
What do you mean by "didn't work"? __XSI_VISIBLE should be the right
thing to use. Your application would have to define, e.g.,
_XOPEN_SOURCE before including the file.
Another point is the && defined(__CYGWIN__). This should go away.
We're trying to make the headers more standards compatible without
going into too much detial what targat provides which function.
> P.S. Is cygwin-patches OK for this sort of thing, or should I have sent it
> to the newlib list?
Ideally to the newlib list, but no worries :)
> From 91ed7816e771a78170555db246e0e35dc6d2ca3e Mon Sep 17 00:00:00 2001
> From: Ken Brown <kbrown@cornell.edu>
> Date: Wed, 8 Jun 2016 17:04:06 -0400
> Subject: [PATCH] Make <unistd.h> declare crypt
>
> This is mandated by Posix and is done by the glibc and FreeBSD headers.
> ---
> newlib/libc/include/sys/unistd.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
> index ef00575..ebae5d8 100644
> --- a/newlib/libc/include/sys/unistd.h
> +++ b/newlib/libc/include/sys/unistd.h
> @@ -31,6 +31,9 @@ int _EXFUN(close, (int __fildes ));
> #if __POSIX_VISIBLE >= 199209
> size_t _EXFUN(confstr, (int __name, char *__buf, size_t __len));
> #endif
> +#if __BSD_VISIBLE && defined(__CYGWIN__)
> +#include <crypt.h>
> +#endif
> #if __XSI_VISIBLE && __XSI_VISIBLE < 700
> char * _EXFUN(ctermid, (char *__s ));
> #endif
> --
> 2.8.3
>
Thanks,
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20160609/035ce28d/attachment.sig>
More information about the Cygwin-patches
mailing list