From: Remi Gacogne Date: Thu, 31 Aug 2023 09:40:46 +0000 (+0200) Subject: arc4random: Fix 'redundant redeclaration’ warnings X-Git-Tag: rec-5.0.0-alpha1~26^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F13197%2Fhead;p=thirdparty%2Fpdns.git arc4random: Fix 'redundant redeclaration’ warnings If `arc4random.hh` is included before `config.h`, the `HAVE_*` defines are not yet available and thus we include the definition of the following functions even though they might be available in the standard headers: - `arc4random` - `arc4random_buf` - `arc4random_uniform` - `explicit_bzero` Yielding warnings: ``` In file included from dns_random.hh:27, from tsigutils.cc:25: ../ext/arc4random/arc4random.hh:9:12: warning: redundant redeclaration of ‘uint32_t arc4random()’ in same scope [-Wredundant-decls] 9 | uint32_t arc4random(void); | ^~~~~~~~~~ In file included from /usr/include/c++/13.2.1/cstdlib:79, from /usr/include/c++/13.2.1/ext/string_conversions.h:43, from /usr/include/c++/13.2.1/bits/basic_string.h:4097, from /usr/include/c++/13.2.1/string:54, from dnsname.hh:26, from tsigutils.cc:23: /usr/include/stdlib.h:657:19: note: previous declaration of ‘__uint32_t arc4random()’ 657 | extern __uint32_t arc4random (void) | ^~~~~~~~~~ ../ext/arc4random/arc4random.hh:12:8: warning: redundant redeclaration of ‘void arc4random_buf(void*, size_t)’ in same scope [-Wredundant-decls] 12 | void arc4random_buf(void* buf, size_t nbytes); | ^~~~~~~~~~~~~~ /usr/include/stdlib.h:661:13: note: previous declaration of ‘void arc4random_buf(void*, size_t)’ 661 | extern void arc4random_buf (void *__buf, size_t __size) | ^~~~~~~~~~~~~~ ../ext/arc4random/arc4random.hh:15:12: warning: redundant redeclaration of ‘uint32_t arc4random_uniform(uint32_t)’ in same scope [-Wredundant-decls] 15 | uint32_t arc4random_uniform(uint32_t upper_bound); | ^~~~~~~~~~~~~~~~~~ /usr/include/stdlib.h:666:19: note: previous declaration of ‘__uint32_t arc4random_uniform(__uint32_t)’ 666 | extern __uint32_t arc4random_uniform (__uint32_t __upper_bound) | ^~~~~~~~~~~~~~~~~~ ../ext/arc4random/arc4random.hh:18:8: warning: redundant redeclaration of ‘void explicit_bzero(void*, size_t)’ in same scope [-Wredundant-decls] 18 | void explicit_bzero(void*, size_t len); ``` --- diff --git a/ext/arc4random/arc4random.hh b/ext/arc4random/arc4random.hh index cff8dd031e..6e01712a4f 100644 --- a/ext/arc4random/arc4random.hh +++ b/ext/arc4random/arc4random.hh @@ -1,8 +1,9 @@ #pragma once - #include #include +#include "config.h" + extern "C" { #ifndef HAVE_ARC4RANDOM