From 7b2108cad1aa963dae663bdabb3840132afbe6b5 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 30 Aug 2021 10:15:35 +0200 Subject: [PATCH] BUILD: tools: properly guard __GLIBC__ with defined() The test on the glibc versions based on #if (__GLIBC > 2 ...) fails to build under -Wundef, let's prepend defined(__GLIBC__) first. --- src/tools.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tools.c b/src/tools.c index cc71d45358..76a0cd7f13 100644 --- a/src/tools.c +++ b/src/tools.c @@ -43,7 +43,7 @@ extern void *__elf_aux_vector; #include #include -#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) #include #endif @@ -4768,7 +4768,7 @@ const char *get_exec_path() { const char *ret = NULL; -#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 16)) long execfn = getauxval(AT_EXECFN); if (execfn && execfn != ENOENT) @@ -4800,7 +4800,7 @@ const char *get_exec_path() static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size) { int ret; -#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) // most detailed one +#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) // most detailed one const ElfW(Sym) *sym; ret = dladdr1(addr, dli, (void **)&sym, RTLD_DL_SYMENT);