wahern / dns

dns.c: Single file non-blocking DNS C library without callbacks or external dependencies.
http://25thandclement.com/~william/projects/dns.c.html
MIT License
256 stars 64 forks source link

#defining defined() in macros is undefined #25

Open bentley opened 6 years ago

bentley commented 6 years ago

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

cc -std=gnu99 -Wall -Wextra -O2 -g -fstack-protector -O2 -pipe  -DDNS_DEBUG -DDNS_MAIN  -o dns dns.c 
dns.c:383:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
#if HAVE___ATOMIC_FETCH_ADD && __GCC_ATOMIC_LONG_LOCK_FREE == 2
    ^
dns.c:375:34: note: expanded from macro 'HAVE___ATOMIC_FETCH_ADD'
#define HAVE___ATOMIC_FETCH_ADD (defined __ATOMIC_RELAXED)
                                 ^
dns.c:392:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
#if HAVE___ATOMIC_FETCH_SUB && __GCC_ATOMIC_LONG_LOCK_FREE == 2
    ^
dns.c:379:33: note: expanded from macro 'HAVE___ATOMIC_FETCH_SUB'
#define HAVE___ATOMIC_FETCH_SUB HAVE___ATOMIC_FETCH_ADD
                                ^
dns.c:375:34: note: expanded from macro 'HAVE___ATOMIC_FETCH_ADD'
#define HAVE___ATOMIC_FETCH_ADD (defined __ATOMIC_RELAXED)
                                 ^
dns.c:788:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns.c:782:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns.c:788:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
dns.c:782:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns.c:843:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns.c:782:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns.c:843:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
dns.c:782:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns.c:849:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns.c:782:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns.c:849:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
dns.c:782:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns.c:909:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
#if DNS_HAVE_SOCKADDR_UN
    ^
dns.c:782:31: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                              ^
dns.c:909:5: warning: macro expansion producing 'defined' has undefined behavior
      [-Wexpansion-to-defined]
dns.c:782:51: note: expanded from macro 'DNS_HAVE_SOCKADDR_UN'
#define DNS_HAVE_SOCKADDR_UN (defined AF_UNIX && !defined _WIN32)
                                                  ^
dns.c:6134:5: warning: macro expansion producing 'defined' has undefined
      behavior [-Wexpansion-to-defined]
#if HAVE_SOCK_CLOEXEC
    ^
dns.c:6118:28: note: expanded from macro 'HAVE_SOCK_CLOEXEC'
#define HAVE_SOCK_CLOEXEC (defined SOCK_CLOEXEC)
                           ^
dns.c:6137:5: warning: macro expansion producing 'defined' has undefined
      behavior [-Wexpansion-to-defined]
#if HAVE_SOCK_NONBLOCK
    ^
dns.c:6122:29: note: expanded from macro 'HAVE_SOCK_NONBLOCK'
#define HAVE_SOCK_NONBLOCK (defined SOCK_NONBLOCK)
                            ^
dns.c:6143:25: warning: macro expansion producing 'defined' has undefined
      behavior [-Wexpansion-to-defined]
#if defined F_SETFD && !HAVE_SOCK_CLOEXEC
                        ^
dns.c:6118:28: note: expanded from macro 'HAVE_SOCK_CLOEXEC'
#define HAVE_SOCK_CLOEXEC (defined SOCK_CLOEXEC)
                           ^
dns.c:6148:28: warning: macro expansion producing 'defined' has undefined
      behavior [-Wexpansion-to-defined]
#if defined O_NONBLOCK && !HAVE_SOCK_NONBLOCK
                           ^
dns.c:6122:29: note: expanded from macro 'HAVE_SOCK_NONBLOCK'
#define HAVE_SOCK_NONBLOCK (defined SOCK_NONBLOCK)
                            ^
dns.c:6206:26: warning: macro expansion producing 'defined' has undefined
      behavior [-Wexpansion-to-defined]
#if (defined F_SETFD && !HAVE_SOCK_CLOEXEC) || (defined O_NONBLOCK && !H...
                         ^
dns.c:6118:28: note: expanded from macro 'HAVE_SOCK_CLOEXEC'
#define HAVE_SOCK_CLOEXEC (defined SOCK_CLOEXEC)
                           ^
dns.c:6206:72: warning: macro expansion producing 'defined' has undefined
      behavior [-Wexpansion-to-defined]
  ...F_SETFD && !HAVE_SOCK_CLOEXEC) || (defined O_NONBLOCK && !HAVE_SOCK_NONB...
                                                               ^
dns.c:6122:29: note: expanded from macro 'HAVE_SOCK_NONBLOCK'
#define HAVE_SOCK_NONBLOCK (defined SOCK_NONBLOCK)
                            ^
16 warnings generated.