diff options
author | Denis Ovsienko <denis@ovsienko.info> | 2021-08-11 00:17:19 +0100 |
---|---|---|
committer | Denis Ovsienko <denis@ovsienko.info> | 2021-08-11 00:17:19 +0100 |
commit | 0c21cb27e629288925f378994eb47a1d90279eab (patch) | |
tree | b6f6629b9cadbd744e7df2f24938d5482b952fc6 | |
parent | 02bc5d9fca019a71c8148790686dc81728d778e4 (diff) |
Fix compiling on Solaris 11.4/AMD64.
In gencode.h and pcap/bpf.h include necessary headers in order not to
depend on other files to do so.
In gencode.c, grammar.c (via grammar.y.in) and scanner.c (via scanner.l)
include gencode.h and grammar.h as early as it takes for the token enum
identifiers not to clash with the named constants defined in system
headers. This fixes the following error with Clang (also with GCC and a
more vague message):
./grammar.h:116:5: error: expected identifier
ESP = 326,
/usr/include/sys/regset.h:86:14: note: expanded from macro 'ESP'
#define ESP 7
In build.sh add an exemption rule for the remaining warnings. Now
libpcap can complete the default matrix build (4 rounds with GCC 7.3.0
and 4 rounds with Clang 6.0.0).
-rw-r--r-- | CHANGES | 2 | ||||
-rwxr-xr-x | build.sh | 14 | ||||
-rw-r--r-- | gencode.c | 9 | ||||
-rw-r--r-- | gencode.h | 1 | ||||
-rw-r--r-- | grammar.y.in | 9 | ||||
-rw-r--r-- | pcap/bpf.h | 2 | ||||
-rw-r--r-- | scanner.l | 11 |
7 files changed, 38 insertions, 10 deletions
@@ -4,7 +4,7 @@ Monthday, Month DD, YYYY: Building and testing: Handle some Autoconf/make errors better. Fix "make releasetar" on AIX, OpenBSD and Solaris. - Fix compiling on Solaris 9. + Fix compiling on Solaris 9/SPARC and 11/AMD64. Address assorted compiler warnings. Monthday, Month DD, YYYY: @@ -50,6 +50,20 @@ clang-*/NetBSD-*) # 'long' to 'suseconds_t' (aka 'int') [-Wshorten-64-to-32] LIBPCAP_TAINTED=yes ;; +clang-*/SunOS-5.11) + # pcap-bpf.c:1044:18: warning: implicit conversion loses integer precision: + # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int') + # [-Wshorten-64-to-32] + # pcap-bpf.c:1045:18: warning: implicit conversion loses integer precision: + # 'uint64_t' (aka 'unsigned long') to 'u_int' (aka 'unsigned int') + # [-Wshorten-64-to-32] + # pcap-bpf.c:1843:22: warning: implicit conversion loses integer precision: + # 'long' to 'int' [-Wshorten-64-to-32] + # fad-getad.c:266:52: warning: implicit conversion loses integer precision: + # 'uint64_t'(aka 'unsigned long') to 'bpf_u_int32' (aka 'unsigned int') + # [-Wshorten-64-to-32] + [ "`uname -p`" = i386 ] && LIBPCAP_TAINTED=yes + ;; esac # shellcheck disable=SC2006 [ "$LIBPCAP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags` @@ -24,6 +24,13 @@ #include <config.h> #endif +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include <pcap-types.h> #ifdef _WIN32 #include <ws2tcpip.h> @@ -69,7 +76,6 @@ #include "ethertype.h" #include "nlpid.h" #include "llc.h" -#include "gencode.h" #include "ieee80211.h" #include "atmuni31.h" #include "sunatmpos.h" @@ -79,7 +85,6 @@ #include "arcnet.h" #include "diag-control.h" -#include "grammar.h" #include "scanner.h" #if defined(linux) @@ -23,6 +23,7 @@ #define gencode_h #include "pcap/funcattrs.h" +#include "pcap/bpf.h" /* bpf_u_int32 */ /* * ATM support: diff --git a/grammar.y.in b/grammar.y.in index 2fbd8615..f8d336ea 100644 --- a/grammar.y.in +++ b/grammar.y.in @@ -71,6 +71,13 @@ #include <config.h> #endif +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include <stdlib.h> #ifndef _WIN32 @@ -92,8 +99,6 @@ struct rtentry; #include "pcap-int.h" -#include "gencode.h" -#include "grammar.h" #include "scanner.h" #ifdef HAVE_NET_PFVAR_H @@ -80,7 +80,7 @@ #define lib_pcap_bpf_h #include <pcap/funcattrs.h> - +#include <pcap-types.h> /* u_char, u_short and u_int */ #include <pcap/dlt.h> #ifdef __cplusplus @@ -24,6 +24,13 @@ */ #include <pcap/pcap-inttypes.h> +/* + * grammar.h requires gencode.h and sometimes breaks in a polluted namespace + * (see ftmacros.h), so include it early. + */ +#include "gencode.h" +#include "grammar.h" + #include "diag-control.h" } @@ -89,10 +96,6 @@ #include "pcap-int.h" -#include "gencode.h" - -#include "grammar.h" - /* * Earlier versions of Flex don't declare these, so we declare them * ourselves to squelch warnings. |