From 08a8e4ffca24680fc2767018e229854a8ff04751 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 21 Feb 2025 18:42:15 +0100 Subject: [PATCH] avoid double declarations (with gcc) ``` from libcurl_unity.c:41: memdebug.h:52:14: error: redundant redeclaration of 'curl_dbg_logfile' [-Werror=redundant-decls] 52 | extern FILE *curl_dbg_logfile; | ^~~~~~~~~~~~~~~~ In file included from altsvc.c:49, from libcurl_unity.c:2: memdebug.h:52:14: note: previous declaration of 'curl_dbg_logfile' with type 'FILE *' 52 | extern FILE *curl_dbg_logfile; | ^~~~~~~~~~~~~~~~ [...] ``` https://github.com/curl/curl/actions/runs/13462106475/job/37619673742?pr=16428#step:36:66 --- lib/memdebug.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/memdebug.h b/lib/memdebug.h index f45d4925f6..8bb7df4fd2 100644 --- a/lib/memdebug.h +++ b/lib/memdebug.h @@ -33,6 +33,11 @@ #include #include "functypes.h" +/* Avoid double definitions/declarations, in case we include this header + again after a 'memdebug_reset.h'. */ +#ifndef HEADER_CURL_MEMDEBUG_H_DECL +#define HEADER_CURL_MEMDEBUG_H_DECL + #if defined(__GNUC__) && __GNUC__ >= 3 # define ALLOC_FUNC __attribute__((__malloc__)) # define ALLOC_SIZE(s) __attribute__((__alloc_size__(s))) @@ -108,6 +113,7 @@ CURL_EXTERN ALLOC_FUNC FILE *curl_dbg_fdopen(int filedes, const char *mode, int line, const char *source); CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source); +#endif /* HEADER_CURL_MEMDEBUG_H_DECL */ #ifndef MEMDEBUG_NODEFINES