This is the mail archive of the cygwin-patches 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]

Re: Declaration of crypt


On 6/9/2016 5:00 AM, Corinna Vinschen wrote:
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.

Ah, that's what I missed. I tried defining __XSI_VISIBLE in the test file, and I still got the implicit declaration warning. I see now, reading /usr/include/sys/features.h, that __XSI_VISIBLE is a private macro and shouldn't have been used in my test.

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.

I wasn't sure that <crypt.h> was portable to all newlib targets.

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 :)

OK, I'll do that next time.

Revised patch attached.

Ken

Attachment: 0001-Make-unistd.h-declare-crypt.patch
Description: Text document


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