You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
_GNU_SOURCE not defined on Debian/Ubuntu (was: c99 does not define getaddrinfo()) #2
When compiling on Debian, I get the following error:
pxyconn.c: In function ‘pxy_sni_resolve_cb’:
pxyconn.c:1524:23: error: dereferencing pointer to incomplete type
pxyconn.c:1524:36: error: dereferencing pointer to incomplete type
pxyconn.c:1525:19: error: dereferencing pointer to incomplete type
pxyconn.c: In function ‘pxy_fd_readcb’:
pxyconn.c:1605:19: error: storage size of ‘hints’ isn’t known
pxyconn.c:1605:19: warning: unused variable ‘hints’ [-Wunused-variable]
The problem is that getaddrinfo() is a POSIX.1g extension and is not available in pure C99. It may work if libevent has also been compiled with --std=c99 because struct evutil_addrinfo will be defined as a full structure. Otherwise, it is just an alias to struct addrinfo which is not defined in netdb.h but still exists as an incomplete type in event2/utils.h.
You can either compile with --std=gnu99 or with -D_POSIX_C_SOURCE=200112L. With the later option, there are additional errors later. Moreover, compiling with --std=gnu99 almost silents out any warnings. I don't know if such a standard is portable outside of gcc.
-D_GNU_SOURCE is supposed to get added to CPPFLAGS automatically when building on a glibc system, which in turn should pull in getaddrinfo() and all the other definitions not in C99 and silence all warnings. SSLsplit is definitely supposed to build warning-free, given recent enough OpenSSL headers. I suspect the auto-detection is not good enough. Can you check the following:
Does the GCC invocation line just before the errors contain -D_GNU_SOURCE?
Does /usr/include/gnu/libc-version.h exist on your system?
Does it build when you run make like this: CPPFLAGS=-D_GNU_SOURCE make?
I have no /usr/include/gnu/libc-version.h but I have a /usr/include/x86_64-linux-gnu/gnu/libc-version.h. This is a change to support multiarch. This should be the same with recent versions of Ubuntu.
And yes, it works fine with CPPFLAGS=-D_GNU_SOURCE make.
Maybe you can grab default search path from gcc with gcc -v -E - < /dev/null.
Activity
droe commentedon May 13, 2012
-D_GNU_SOURCEis supposed to get added toCPPFLAGSautomatically when building on a glibc system, which in turn should pull ingetaddrinfo()and all the other definitions not in C99 and silence all warnings. SSLsplit is definitely supposed to build warning-free, given recent enough OpenSSL headers. I suspect the auto-detection is not good enough. Can you check the following:-D_GNU_SOURCE?/usr/include/gnu/libc-version.hexist on your system?CPPFLAGS=-D_GNU_SOURCE make?vincentbernat commentedon May 13, 2012
Here is the line used:
I have no
/usr/include/gnu/libc-version.hbut I have a/usr/include/x86_64-linux-gnu/gnu/libc-version.h. This is a change to support multiarch. This should be the same with recent versions of Ubuntu.And yes, it works fine with
CPPFLAGS=-D_GNU_SOURCE make.Maybe you can grab default search path from gcc with
gcc -v -E - < /dev/null.Unconditionally define _GNU_SOURCE
droe commentedon May 13, 2012
Fixed in latest master. Thank you for reporting the issue.