From 66260f81f4e9b96a9b3c644153bb399d72bb5a76 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Tue, 13 May 2025 20:41:57 +0800 Subject: [PATCH] UNUSED: UNUSED may be defined elsewhere. Give priority to using macros defined by third-party libraries Signed-off-by: wangmingrong1 --- include/nuttx/compiler.h | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 2c93231439..20709674b8 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -576,7 +576,9 @@ /* Indicate that a local variable is not used */ -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif # if defined(__clang__) # define no_builtin(n) __attribute__((no_builtin(n))) @@ -708,7 +710,9 @@ /* Indicate that a local variable is not used */ -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif /* It is assumed that the system is build using the small * data model with storage defaulting to internal RAM. @@ -901,7 +905,9 @@ /* Indicate that a local variable is not used */ -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif /* Older Zilog compilers support both types double and long long, but the * size is 32-bits (same as long and single precision) so it is safer to say @@ -992,7 +998,9 @@ /* Indicate that a local variable is not used */ -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif # define CONFIG_CPP_HAVE_VARARGS 1 /* Supports variable argument macros */ # define CONFIG_HAVE_FILENAME 1 /* Has __FILE__ */ @@ -1088,7 +1096,9 @@ # undef CONFIG_LONG_IS_NOT_INT # undef CONFIG_PTR_IS_NOT_INT -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) # define return_address(x) 0 @@ -1179,7 +1189,9 @@ # undef CONFIG_LONG_IS_NOT_INT # undef CONFIG_PTR_IS_NOT_INT -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) # define return_address(x) 0 @@ -1261,7 +1273,9 @@ # undef CONFIG_HAVE_DOUBLE # undef CONFIG_HAVE_LONG_DOUBLE -# define UNUSED(a) ((void)(1 || &(a))) +# ifndef UNUSED +# define UNUSED(a) ((void)(1 || &(a))) +# endif # define offsetof(a, b) ((size_t)(&(((a *)(0))->b))) # define return_address(x) 0