From 44b5e4eed0f2f119d312fe718c2124250c8626f9 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Fri, 2 Feb 2024 13:40:28 +0100 Subject: [PATCH 51/N] Work around fragile `#include` in binutils MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `bfd.h` header file that is included in `binutils` has the line `#include "ansidecl.h"`, which is fragile because it prefers Cygwin's `include/ansidecl.h` (as opposed to `#include `, which would only look in the system include paths). This matters because as of v2.42, `bfd.h` also makes use of the `ATTRIBUTE_WARN_UNUSED_RESULT` macro. So let's just copy that macro (and while at it, the other `ATTRIBUTE_*` macros) from binutils' `ansidecl.h` file, to avoid compile errors while compiling `dumper.o` that look like this: /usr/include/bfd.h:2770:1: error: expected initializer before ‘ATTRIBUTE_WARN_UNUSED_RESULT’ 2770 | ATTRIBUTE_WARN_UNUSED_RESULT; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Johannes Schindelin --- include/ansidecl.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/ansidecl.h b/include/ansidecl.h index 6e4bfc2..ceb356e 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -283,6 +283,49 @@ So instead we use the macro below and test it against specific values. */ # endif /* GNUC >= 4.9 */ #endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */ +/* Attribute 'nonstring' was valid as of gcc 8. */ +#ifndef ATTRIBUTE_NONSTRING +# if GCC_VERSION >= 8000 +# define ATTRIBUTE_NONSTRING __attribute__ ((__nonstring__)) +# else +# define ATTRIBUTE_NONSTRING +# endif +#endif + +/* Attribute `alloc_size' was valid as of gcc 4.3. */ +#ifndef ATTRIBUTE_RESULT_SIZE_1 +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_RESULT_SIZE_1 __attribute__ ((alloc_size (1))) +# else +# define ATTRIBUTE_RESULT_SIZE_1 +#endif +#endif + +#ifndef ATTRIBUTE_RESULT_SIZE_2 +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_RESULT_SIZE_2 __attribute__ ((alloc_size (2))) +# else +# define ATTRIBUTE_RESULT_SIZE_2 +#endif +#endif + +#ifndef ATTRIBUTE_RESULT_SIZE_1_2 +# if (GCC_VERSION >= 4003) +# define ATTRIBUTE_RESULT_SIZE_1_2 __attribute__ ((alloc_size (1, 2))) +# else +# define ATTRIBUTE_RESULT_SIZE_1_2 +#endif +#endif + +/* Attribute `warn_unused_result' was valid as of gcc 3.3. */ +#ifndef ATTRIBUTE_WARN_UNUSED_RESULT +# if GCC_VERSION >= 3003 +# define ATTRIBUTE_WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) +# else +# define ATTRIBUTE_WARN_UNUSED_RESULT +# endif +#endif + /* We use __extension__ in some places to suppress -pedantic warnings about GCC extensions. This feature didn't work properly before gcc 2.8. */