gpgme-1.8.0 does not build on Mac OS X
Jeffrey Stedfast
jestedfa at microsoft.com
Mon Feb 6 22:49:39 CET 2017
Hey all,
It turns out that gpgme-1.8.0 does not build on Mac OS X (tested only on Sierra 10.12.2 with Xcode 8.2), but 1.7.0 does.
The compile failures are all from lang/cpp/src/*result.cpp due to strdup() being undeclared.
Source files such as src/get-env.c, data.c, etc also warn about strdup() being undeclared but do not error out. I suspect the issue is due to c++ being more strict.
I did a quick comparison of gpgme-1.7.0 and 1.8.0 and discovered the problem was that 1.8.0 added #include “config.h”, so it appears that something in config.h is making the c++ compiler fail on Mac OS X.
I took a look at /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h and it only defined strdup() if __DARWIN_C_LEVEL >= 200112L (stpcpy(), another source of compiler *warnings*, is likewise only defined if __DARWIN_C_LEVEL >= 200809L).
After a bit of investigation, I eventually came to sys/cdefs.h which has the following:
/* Deal with various X/Open Portability Guides and Single UNIX Spec. */
#ifdef _XOPEN_SOURCE
#if _XOPEN_SOURCE - 0L >= 700L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200809L)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#elif _XOPEN_SOURCE - 0L >= 600L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 200112L)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#elif _XOPEN_SOURCE - 0L >= 500L && (!defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE - 0L < 199506L)
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199506L
#endif
#endif
Sure enough, gpgme’s config.h defines _XOPEN_SOURCE to be 500.
After modifying the definition of _XOPEN_SOURCE to 700 in my config.h, gpgme-1.8.0 built fine although there are still a few warnings in the c sources:
conversion.c:519:14: warning: implicit declaration of function 'timegm' is invalid in C99 [-Wimplicit-function-declaration]
return timegm (&buf);
^
data.c:196:11: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
if (enc < 0 || enc > GPGME_DATA_ENCODING_MIME)
~~~ ^ ~
key.c:293:16: warning: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Wnon-literal-null-conversion]
sig->uid = '\0';
^~~~
engine-gpg.c:1160:11: warning: comparison of unsigned enum expression >= 0 is always true [-Wtautological-compare]
if (r >= 0)
~ ^ ~
engine-gpg.c:2512:15: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
if (asprintf (r_line,
^
engine-gpgsm.c:399:11: warning: implicit declaration of function 'asprintf' is invalid in C99 [-Wimplicit-function-declaration]
if (asprintf (&optstr, "OPTION display=%s", dft_display) < 0)
^
engine-gpgsm.c:639:21: warning: comparison of unsigned enum expression >= 0 is always true [-Wtautological-compare]
if (r >= 0 && status_fnc && !cb_err)
~ ^ ~
engine-gpgsm.c:990:10: warning: comparison of unsigned enum expression >= 0 is always true [-Wtautological-compare]
if (r >= 0)
~ ^ ~
Looking into asprintf() being undefined, it turns out stdio.h only defines asprintf() on Mac OS X if __DARWIN_C_LEVEL >= __DARWIN_C_FULL and __DARWIN_C_FULL is defined to be 900000L, so configure.ac may also need to define __DARWIN_C_LEVEL as 900000L for Mac OS X rather than trying to define _XOPEN_SOURCE alone.
Hope that helps,
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20170206/5eb7e8d4/attachment.html>
More information about the Gnupg-devel
mailing list