]> The Tcpdump Group git mirrors - libpcap/commitdiff
Include <sys/types.h> properly.
authorDenis Ovsienko <[email protected]>
Tue, 21 Jun 2022 13:51:46 +0000 (14:51 +0100)
committerDenis Ovsienko <[email protected]>
Tue, 21 Jun 2022 14:04:27 +0000 (15:04 +0100)
Follow up on earlier commits (0c21cb2341acb8f4840dc69f105d) and
try to fix the last remaining issue.

In pcap/bpf.h do not try to duplicate the contents of pcap-types.h, it
was a bad idea of mine because in a public header HAVE_SYS_TYPES_H is
out of place.  Instead of that in pcap/bpf.h trust the including file
to have unsiged integer types defined (usually by means of including
either pcap/pcap.h or pcap-types.h).  Include pcap-types.h not from
gencode.c, but from gencode.h, so the latter can include pcap/bpf.h and
itself can be included early.  Add a comment.

gencode.c
gencode.h
pcap/bpf.h

index ea272e17649aff9c1123b88d8f0c01ec76f55067..13db75db76b78eba950fdbee5a0a86bd5be8801d 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -23,7 +23,6 @@
 #include <config.h>
 #endif
 
-#include <pcap-types.h>
 #ifdef _WIN32
   #include <ws2tcpip.h>
 #else
index 9631dd02ee08e66bb254110dad0b094b3a70b919..93ca5216b55614403c90ad964bbe93e5b9166e2d 100644 (file)
--- a/gencode.h
+++ b/gencode.h
 #define gencode_h
 
 #include "pcap/funcattrs.h"
+/*
+ * pcap/bpf.h (a public header) needs u_char, u_short and u_int, which can be
+ * made available via either pcap-types.h (a private header) or pcap/pcap.h
+ * (a public header), none of which pcap/bpf.h includes.  Include the private
+ * header to keep things simple, this way this private header should compile
+ * even if included early from another file.
+ */
+#include "pcap-types.h"
 #include "pcap/bpf.h" /* bpf_u_int32 and BPF_MEMWORDS */
 
 /*
index f813258224c33af00d77127b84d5c4f2fcebdf09..a8eb177b43bc207a77e1eae804c965c8cc64718c 100644 (file)
 #if !defined(_NET_BPF_H_) && !defined(_NET_BPF_H_INCLUDED) && !defined(_BPF_H_) && !defined(_H_BPF) && !defined(lib_pcap_bpf_h)
 #define lib_pcap_bpf_h
 
-/* u_char, u_short and u_int */
-#if defined(_WIN32)
-  #include <winsock2.h>
-#elif defined(HAVE_SYS_TYPES_H)
-  #include <sys/types.h>
-#endif
-
 #include <pcap/funcattrs.h>
 #include <pcap/dlt.h>