mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-03 17:26:24 -04:00
Define _GNU_SOURCE
properly/consistently per autoconf
Although `_GNU_SOURCE` can be defined as an arbitrary #define per the glibc docs [1], it's best to define it in a manner consistent with the way that autoconf defines it, i.e., `1`. While this shouldn't matter in most cases, it does when the headers from other projects follow the poorly defined GNU convention implemented by autoconf and are included after the libevent's util.h header. An example failure with clang, similar to the failure I encountered, is as follows: ``` $ printf "#define _GNU_SOURCE\n#define _GNU_SOURCE 1" | clang -c -x c - <stdin>:2:9: warning: '_GNU_SOURCE' macro redefined [-Wmacro-redefined] ^ <stdin>:1:9: note: previous definition is here ^ 1 warning generated. ``` This happened when compiling python [2] with a stale homebrew util.h file from libevent (which admittedly would not happen in a correct libevent install, as the header should be installed under /usr/local/include/event2/util.h). However, if both headers had been combined (which is more likely), it would have failed as shown above. Removing the ad hoc definition unbreaks compiling python's pyconfig.h.in header when included after util.h from libevent. 1. http://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html 2. https://github.com/python/cpython/blob/master/configure.ac#L126 Closes: #773 (cherry-picked) Signed-off-by: Enji Cooper <yaneurabeya@gmail.com> (cherry picked from commit 5f87be42f0ae0126938624a1419a572607078217)
This commit is contained in:
parent
3d1a7a1d45
commit
00ba9fa299
@ -334,7 +334,7 @@ if (NOT DEFINED _GNU_SOURCE)
|
||||
endif()
|
||||
|
||||
if (_GNU_SOURCE)
|
||||
add_definitions(-D_GNU_SOURCE)
|
||||
add_definitions(-D_GNU_SOURCE=1)
|
||||
endif()
|
||||
|
||||
CHECK_INCLUDE_FILE(sys/types.h EVENT__HAVE_SYS_TYPES_H)
|
||||
|
@ -478,7 +478,7 @@ fi
|
||||
AC_MSG_CHECKING(for F_SETFD in fcntl.h)
|
||||
AC_EGREP_CPP(yes,
|
||||
[
|
||||
#define _GNU_SOURCE
|
||||
#define _GNU_SOURCE 1
|
||||
#include <fcntl.h>
|
||||
#ifdef F_SETFD
|
||||
yes
|
||||
@ -667,7 +667,7 @@ AC_CHECK_SIZEOF(off_t)
|
||||
AC_CHECK_SIZEOF(time_t)
|
||||
|
||||
AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo, struct sockaddr_storage], , ,
|
||||
[#define _GNU_SOURCE
|
||||
[#define _GNU_SOURCE 1
|
||||
#include <sys/types.h>
|
||||
#ifdef HAVE_NETINET_IN_H
|
||||
#include <netinet/in.h>
|
||||
|
@ -58,9 +58,6 @@ extern "C" {
|
||||
#endif
|
||||
#include <stdarg.h>
|
||||
#ifdef EVENT__HAVE_NETDB_H
|
||||
#if !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user