[v2,2/3] bfd: guard ARCH_SIZE uses to avoid -Wundef
Commit Message
bfd/
* elf-bfd.h: Use `#if defined(ARCH_SIZE) && (ARCH_SIZE == 64)` and
`#elif defined(ARCH_SIZE) && (ARCH_SIZE == 32)` instead of testing
ARCH_SIZE directly, to silence -Wundef when ARCH_SIZE is not defined.
Signed-off-by: Andrew Hanson <andrew@andrewhanson.dev>
---
bfd/elf-bfd.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
Comments
On Sep 15 2025, Andrew Hanson wrote:
> diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
> index de7cc410a99..3db99097800 100644
> --- a/bfd/elf-bfd.h
> +++ b/bfd/elf-bfd.h
> @@ -47,10 +47,9 @@ extern "C" {
>
> /* If size isn't specified as 64 or 32, NAME macro should fail. */
> #ifndef NAME
> -#if ARCH_SIZE == 64
> +#if defined(ARCH_SIZE) && ARCH_SIZE == 64
> #define NAME(x, y) x ## 64 ## _ ## y
> -#endif
> -#if ARCH_SIZE == 32
> +#elif defined(ARCH_SIZE) && ARCH_SIZE == 32
> #define NAME(x, y) x ## 32 ## _ ## y
> #endif
> #endif
Just put #ifdef ARCH_SIZE around the block, no need to duplicate it.
@@ -47,10 +47,9 @@ extern "C" {
/* If size isn't specified as 64 or 32, NAME macro should fail. */
#ifndef NAME
-#if ARCH_SIZE == 64
+#if defined(ARCH_SIZE) && ARCH_SIZE == 64
#define NAME(x, y) x ## 64 ## _ ## y
-#endif
-#if ARCH_SIZE == 32
+#elif defined(ARCH_SIZE) && ARCH_SIZE == 32
#define NAME(x, y) x ## 32 ## _ ## y
#endif
#endif