Skip to content
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

_GNU_SOURCE not defined on Debian/Ubuntu (was: c99 does not define getaddrinfo()) #2

Closed
vincentbernat opened this issue May 13, 2012 · 3 comments
Assignees

Comments

@vincentbernat
Copy link

Hi!

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.

@ghost ghost assigned droe May 13, 2012
@droe
Copy link
Owner

droe commented May 13, 2012

-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?

@vincentbernat
Copy link
Author

Here is the line used:

cc -c   -DDISABLE_SSLV2_SESSION_CACHE -DHAVE_NETFILTER -D"BNAME=\"sslsplit\"" -D"PNAME=\"SSLsplit\"" -D"VERSION=\"0.4.4\"" -D"FEATURES=\"-DDISABLE_SSLV2_SESSION_CACHE -DHAVE_NETFILTER\"" -D"BUILD_DATE=\"2012-05-13\"" -g   -pthread -std=c99 -Wall -Wextra -pedantic -D_FORTIFY_SOURCE=2 -o pxyconn.o pxyconn.c

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.

droe added a commit that referenced this issue May 13, 2012
Get rid of the fragile glibc auto-detection mechanism and define
_GNU_SOURCE unconditionally in order to fix the build on recent GNU libc
systems such as Debian and Ubuntu.  On non-GNU libc implementations,
_GNU_SOURCE should not have any effect.

Issue:          #2
Reported by:    Vincent Bernat
@droe
Copy link
Owner

droe commented May 13, 2012

Fixed in latest master. Thank you for reporting the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants