summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorEnji Cooper <yaneurabeya@gmail.com>2019-02-25 11:59:15 -0800
committerAzat Khuzhin <azat@libevent.org>2019-02-27 23:18:12 +0300
commit5f87be42f0ae0126938624a1419a572607078217 (patch)
treefd0cb4a95279f8d09e1727e611bf64e8a9ef5657 /include
parenta30d6d85219ea80c16df6da4f6a9430254e5a0da (diff)
downloadlibevent-5f87be42f0ae0126938624a1419a572607078217.tar.gz
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>
Diffstat (limited to 'include')
-rw-r--r--include/event2/util.h3
1 files changed, 0 insertions, 3 deletions
diff --git a/include/event2/util.h b/include/event2/util.h
index 7c872737..e6df6289 100644
--- a/include/event2/util.h
+++ b/include/event2/util.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