From 50b6f8c85c6ed9e7e0d98a111a8690b20e6474e6 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Fri, 14 Jun 2024 15:32:38 -0700 Subject: [PATCH] [include][compiler.h] fix a warning with gcc --- top/include/lk/compiler.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/top/include/lk/compiler.h b/top/include/lk/compiler.h index 8bdb49c8b..60c0a8128 100644 --- a/top/include/lk/compiler.h +++ b/top/include/lk/compiler.h @@ -20,10 +20,14 @@ #define likely(x) __builtin_expect(!!(x), 1) #define unlikely(x) __builtin_expect(!!(x), 0) #define __UNUSED __attribute__((__unused__)) +#if __clang__ // Per https://clang.llvm.org/docs/AttributeReference.html#used // __used__ does not prevent linkers from removing unused sections // (if --gc-sections is passed). Need to specify "retain" as well. #define __USED __attribute__((__used__, retain)) +#else +#define __USED __attribute__((__used__)) +#endif #define __PACKED __attribute__((packed)) #define __ALIGNED(x) __attribute__((aligned(x))) #define __PRINTFLIKE(__fmt,__varargs) __attribute__((__format__ (__printf__, __fmt, __varargs)))