Compiling 'compat/obstack.c' with Clang on Linux and macOS fails with different errors: On Linux: CC compat/obstack.o compat/obstack.c:330:31: error: incompatible pointer types initializing 'void (*)(void) __attribute__((noreturn))' with an expression of type 'void (void)' [-Werror,-Wincompatible-pointer-types] __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void) ^ Remove '__attribute_noreturn__' from the function's declaration and definition to resolve this build error. On macOS: compat/obstack.h:223:3: error: expected function body after function declarator __attribute_pure__; ^ compat/obstack.h:151:29: note: expanded from macro '__attribute_pure__' # define __attribute_pure__ _GL_ATTRIBUTE_PURE Remove '__attribute_pure__' to resolve this build error. With this patch it's now possible to compile 'compat/obstack.c' both with GCC and Clang on both on Linux and macOS. Signed-off-by: SZEDER Gábor <szeder.dev@xxxxxxxxx> --- compat/obstack.c | 4 ++-- compat/obstack.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compat/obstack.c b/compat/obstack.c index 17fa95d46c..6ef8cecb8a 100644 --- a/compat/obstack.c +++ b/compat/obstack.c @@ -231,7 +231,7 @@ _obstack_newchunk (struct obstack *h, _OBSTACK_SIZE_T length) /* Suppress -Wmissing-prototypes warning. We don't want to declare this in obstack.h because it is just for debugging. */ -int _obstack_allocated_p (struct obstack *h, void *obj) __attribute_pure__; +int _obstack_allocated_p (struct obstack *h, void *obj); int _obstack_allocated_p (struct obstack *h, void *obj) @@ -327,7 +327,7 @@ print_and_abort (void) abort gracefully or use longjump - but shouldn't return. This variable by default points to the internal function 'print_and_abort'. */ -__attribute_noreturn__ void (*obstack_alloc_failed_handler) (void) +void (*obstack_alloc_failed_handler) (void) = print_and_abort; # endif /* !_OBSTACK_NO_ERROR_HANDLER */ #endif /* !_OBSTACK_ELIDE_CODE */ diff --git a/compat/obstack.h b/compat/obstack.h index 811de588a4..f8f9625121 100644 --- a/compat/obstack.h +++ b/compat/obstack.h @@ -219,15 +219,14 @@ extern int _obstack_begin_1 (struct obstack *, _OBSTACK_SIZE_T, _OBSTACK_SIZE_T, void *(*) (void *, size_t), void (*) (void *, void *), void *); -extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *) - __attribute_pure__; +extern _OBSTACK_SIZE_T _obstack_memory_used (struct obstack *); /* Error handler called when 'obstack_chunk_alloc' failed to allocate more memory. This can be set to a user defined function which should either abort gracefully or use longjump - but shouldn't return. The default action is to print a message and abort. */ -extern __attribute_noreturn__ void (*obstack_alloc_failed_handler) (void); +extern void (*obstack_alloc_failed_handler) (void); /* Exit value used when 'print_and_abort' is used. */ extern int obstack_exit_failure; -- 2.22.0.589.g5bd7971b91