sustrik / libdill

Structured concurrency in C
MIT License
1.68k stars 156 forks source link

#defining defined() in macros is undefined #143

Closed bentley closed 6 years ago

bentley commented 6 years ago

Clang-5.0.1 on OpenBSD complains when compiling dns/dns.c:

cc -DPACKAGE_NAME="libdill" -DPACKAGE_TARNAME="libdill" -DPACKAGE_VERSION="2.4" -DPACKAGE_STRING="libdill 2.4" -DPACKAGE_BUGREPORT="sustrik@250bpm.com" -DPACKAGE_URL="http://libdill.org/" -DPACKAGE="libdill" -DVERSION="2.4" -DDILL_THREADS=1 -DDILL_PTHREAD=1 -DHAVE_POSIX_MEMALIGN=1 -DHAVE_MPROTECT=1 -DHAVE_CLOCK_GETTIME=1 -DHAVE_KQUEUE=1 -DHAVE_KQUEUE=1 -DHAVE_STRUCT_SOCKADDR_SA_LEN=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=".libs/" -DDILL_SHARED=1 -I. -pthread -fvisibility=hidden -DDILL_EXPORTS -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 -O2 -pipe -g -MT dns/libdill_la-dns.lo -MD -MP -MF dns/.deps/libdill_la-dns.Tpo -c dns/dns.c -fPIC -DPIC -o dns/.libs/libdill_la-dns.o
dns/dns.c:311:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if HAVE___ATOMIC_FETCH_ADD && __GCC_ATOMIC_LONG_LOCK_FREE == 2
    ^
dns/dns.c:303:34: note: expanded from macro 'HAVE___ATOMIC_FETCH_ADD'
#define HAVE___ATOMIC_FETCH_ADD (defined __ATOMIC_RELAXED)
                                 ^
dns/dns.c:320:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if HAVE___ATOMIC_FETCH_SUB && __GCC_ATOMIC_LONG_LOCK_FREE == 2
    ^
dns/dns.c:307:33: note: expanded from macro 'HAVE___ATOMIC_FETCH_SUB'
#define HAVE___ATOMIC_FETCH_SUB HAVE___ATOMIC_FETCH_ADD
                                ^
dns/dns.c:303:34: note: expanded from macro 'HAVE___ATOMIC_FETCH_ADD'
#define HAVE___ATOMIC_FETCH_ADD (defined __ATOMIC_RELAXED)
                                 ^
dns/dns.c:676:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns/dns.c:670:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns/dns.c:676:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
dns/dns.c:670:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns/dns.c:731:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns/dns.c:670:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns/dns.c:731:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
dns/dns.c:670:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns/dns.c:737:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns/dns.c:670:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns/dns.c:737:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
dns/dns.c:670:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns/dns.c:797:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns/dns.c:670:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns/dns.c:797:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
dns/dns.c:670:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
10 warnings generated.
sustrik commented 6 years ago

Unfortunately, dns.c is a third-party library. In case you really want this to be fixed you can report the problem here: https://github.com/wahern/dns