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 Jun  9 08:05, Ken Brown wrote:
> 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.

Oh, drat, no, it isn't.  I'm sorry, I didn't see the #include and just
automatically implied a prototype at this point.  My excuse is that I
have a date for an eye test at my optometrist tomorrow :}

Can you please define crypt, encrypt and setkey explicitely in unistd.h
per POSIX, rather than including crypt.h?  This would not only be target
independent, it would also be more correct.  As a side effect I will 
have to come up with a new version of the crypt package, because our
crypt.h is using a wrong prototypes for setkey (const is missing).


Thanks a lot and sorry again,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

Attachment: signature.asc
Description: PGP signature


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