-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: implicit declaration of function ‘strnlen’ #25
Comments
So the question is: how should it look like? |
Solaris has problems as well: ===> Dear Guido, We are reported that in some versions of Solaris,
|
I would like to suggest using the same strategy as gnuplot does. In AC_CHECK_FUNCS(... strndup strnlen ...) and then #ifndef HAVE_STRNDUP
char *strndup __PROTO((const char * str, size_t n));
#endif
#ifndef HAVE_STRNLEN
size_t strnlen __PROTO((const char *str, size_t n));
#endif and #ifndef HAVE_STRNLEN
size_t
strnlen(const char *str, size_t n)
{
const char * stop = (char *)memchr(str, '\0', n);
return stop ? stop - str : n;
}
#endif
#ifndef HAVE_STRNDUP
char *
strndup(const char * str, size_t n)
{
char * ret = NULL;
size_t len = strnlen(str, n);
ret = (char *) malloc(len + 1);
if (ret == NULL) return NULL;
ret[len] = '\0';
return (char *)memcpy(ret, str, len);
}
#endif |
The strnlen function is only defined in POSIX.1-2008. It is missing on Solaris 10 or Mac OS X 10.6 for example.
The strnlen function is only defined in POSIX.1-2008. It is missing on Solaris 10 or Mac OS X 10.6 for example.
provide a workaround for missing strnlen #25
The patch looks great, I have edited it slightly. Please check. |
I now tested on Mac OS X 10.6, Sun OS 5.10 and 11. It seems OK on those. (@kencu: you can try to remove the SL fixes once v0.13.69 gets released.) Compiling on MSYS2 (mentioned in #2) failed for other reasons (#6). MinGW-packages stayed at version 0.13.62, so I could not check how they might have fixed the problem. |
done. |
libzzip 0.13.68 fails to build on older systems, such as Mac OS X 10.6 Snow Leopard and earlier, that do not have the
strnlen
function:See #2 for prior discussion of this issue.
The text was updated successfully, but these errors were encountered: