]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix "C++ One Definition Rule" warnings in XSK 14037/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 5 Apr 2024 08:20:49 +0000 (10:20 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 5 Apr 2024 08:20:49 +0000 (10:20 +0200)
It turns out we need to include the linux specific headers AFTER the
regular ones, because it then detects that some types have already been
defined (`sockaddr_in6` for example) and does not attempt to re-define
them, which otherwise breaks the C++ One Definition Rule

pdns/xsk.cc

index 72f4791dd8a3956759362a0154d631dcdcc29f63..e507c0f889e5970039968a16399d9c37e569f9a3 100644 (file)
 #include <cstring>
 #include <fcntl.h>
 #include <iterator>
-#include <linux/bpf.h>
-#include <linux/if_ether.h>
-#include <linux/if_link.h>
-#include <linux/if_xdp.h>
-#include <linux/ip.h>
-#include <linux/ipv6.h>
-#include <linux/tcp.h>
-#include <linux/types.h>
-#include <linux/udp.h>
 #include <net/if.h>
 #include <net/if_arp.h>
 #include <netinet/in.h>
@@ -61,6 +52,21 @@ extern "C"
 #include "gettime.hh"
 #include "xsk.hh"
 
+/* we need to include the linux specific headers AFTER the regular
+   ones, because it then detects that some types have already been
+   defined (sockaddr_in6 for example) and does not attempt to
+   re-define them, which otherwise breaks the C++ One Definition Rule
+*/
+#include <linux/bpf.h>
+#include <linux/if_ether.h>
+#include <linux/if_link.h>
+#include <linux/if_xdp.h>
+#include <linux/ip.h>
+#include <linux/ipv6.h>
+#include <linux/tcp.h>
+#include <linux/types.h>
+#include <linux/udp.h>
+
 #ifdef DEBUG_UMEM
 namespace
 {