From: Mark Wielaard Date: Fri, 4 Apr 2025 11:50:04 +0000 (+0200) Subject: lib: Prevent double inclusion of config.h through system.h X-Git-Tag: elfutils-0.193~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f33f4c85581045ae493e7f12c6ba1bf5829d8192;p=thirdparty%2Felfutils.git lib: Prevent double inclusion of config.h through system.h Files that include both and "system.h" might include config.h twice. Prevent that by adding a guard check in system.h before including config.h. * lib/crc32.c: Use #ifdef HAVE_CONFIG_H instead of #if. * lib/error.h: Check HAVE_CONFIG_H before including config.h. * lib/system.h: Check both HAVE_CONFIG_H and whether EU_CONFIG_H is defined before including config.h. Suggested-by: Dmitry V. Levin Signed-off-by: Mark Wielaard --- diff --git a/lib/crc32.c b/lib/crc32.c index 758602ea..eae65822 100644 --- a/lib/crc32.c +++ b/lib/crc32.c @@ -25,7 +25,7 @@ the GNU Lesser General Public License along with this program. If not, see . */ -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include #endif diff --git a/lib/error.c b/lib/error.c index 5186fc15..75c9eafb 100644 --- a/lib/error.c +++ b/lib/error.c @@ -26,7 +26,9 @@ the GNU Lesser General Public License along with this program. If not, see . */ -#include +#ifdef HAVE_CONFIG_H +# include +#endif #if !defined(HAVE_ERROR_H) && defined(HAVE_ERR_H) #include diff --git a/lib/system.h b/lib/system.h index 0698e5ff..c17e2aa0 100644 --- a/lib/system.h +++ b/lib/system.h @@ -31,7 +31,12 @@ #ifndef LIB_SYSTEM_H #define LIB_SYSTEM_H 1 -#include +/* Prevent double inclusion of config.h, config.h includes eu-config.h. */ +#ifdef HAVE_CONFIG_H +#ifndef EU_CONFIG_H +# include +#endif +#endif #include #include