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).
(cherry picked from commit
0c21cb27e629288925f378994eb47a1d90279eab)
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.
Wednesday, June 9, 2021:
# '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`
#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>
#include "ethertype.h"
#include "nlpid.h"
#include "llc.h"
-#include "gencode.h"
#include "ieee80211.h"
#include "atmuni31.h"
#include "sunatmpos.h"
#include "arcnet.h"
#include "diag-control.h"
-#include "grammar.h"
#include "scanner.h"
#if defined(linux)
#define gencode_h
#include "pcap/funcattrs.h"
+#include "pcap/bpf.h" /* bpf_u_int32 */
/*
* ATM support:
#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
#include "pcap-int.h"
-#include "gencode.h"
-#include "grammar.h"
#include "scanner.h"
#ifdef HAVE_NET_PFVAR_H
#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
*/
#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"
}
#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.