Skip to content

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

Closed

Description

@vincentbernat

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.

Activity

  1. ghost assigned on May 13, 2012
  2. droe commented on May 13, 2012

    @droe
    Owner

    -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?
  3. vincentbernat commented on May 13, 2012

    @vincentbernat
    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.

  4. added a commit that references this issue on May 13, 2012
  5. droe commented on May 13, 2012

    @droe
    Owner

    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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions