]> The Tcpdump Group git mirrors - libpcap/commitdiff
Fix build on Haiku
authorFrançois Revol <[email protected]>
Fri, 8 Jul 2022 21:24:43 +0000 (23:24 +0200)
committerGuy Harris <[email protected]>
Thu, 14 Jul 2022 05:12:58 +0000 (22:12 -0700)
This fixes #1114.

C++11 forbids declaring types inside typeof and offsetof,
so we drop the macro call and declare the struct separately
for the only use of the call.

(cherry picked from commit d0ba0d53f2dad05d7eb3ba12f508eea3464a855f)

pcap-haiku.cpp

index 8b0009c58543200402f0083ff0446cdea044321b..4606ca0e252e5038b7956e1b193c17f0886c98f5 100644 (file)
@@ -249,7 +249,11 @@ pcap_create_interface(const char *device, char *errorBuffer)
                return NULL;
        }
 
-       pcap_t* handle = PCAP_CREATE_COMMON(errorBuffer, struct pcap_haiku);
+       struct wrapper_struct { pcap_t __common; struct pcap_haiku __private; };
+       pcap_t* handle = pcap_create_common(errorBuffer,
+               sizeof (struct wrapper_struct),
+               offsetof (struct wrapper_struct, __private));
+
        if (handle == NULL) {
                snprintf(errorBuffer, PCAP_ERRBUF_SIZE, "malloc: %s", strerror(errno));
                close(socket);