For all supported versions of gcc (major version 3 and above), functions
and variables may be declared with __attribute__((unused)) to suppress
warnings if they are declared but unused.
This shouldn't be confused with functions being declared with
__attribute__((used)). This specifies that the function code shall still
be emitted even if it appears to be unreferenced, normally used if
embedded in inline assembly. For gcc 3.4 and later, unreferenced static
variables and functions are not emitted so this attribute is necessary to
force variables and functions to be output. Earlier versions of gcc can
simply use __attribute__((unused)) to suppress warnings about such
variables: we do not require any special classification to ensure they are
emitted.
We introduce __attribute_unused__ for variables that should not produce a
compile warning if they can, due to preprocessor macros, go unreferenced.
Signed-off-by: David Rientjes <[email protected]>
---
include/linux/compiler-gcc.h | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -37,3 +37,19 @@
#define noinline __attribute__((noinline))
#define __attribute_pure__ __attribute__((pure))
#define __attribute_const__ __attribute__((__const__))
+
+/*
+ * __attribute_unused__ shall be used for functions or variables to suppress
+ * warnings when they may be declared but, due to preprocessor macros,
+ * commenting, etc., go unreferenced.
+ *
+ * In contrast, __attribute_used__ shall be used only for functions. gcc <3.4
+ * emits code for static functions that are unreferenced and outputs a warning.
+ * __attribute_used__ will correctly suppress this warning. gcc >=3.4 does not
+ * emit code for static functions that are unreferenced (and thus there is no
+ * warning), but __attribute_used__ forces the function code to be output. Use
+ * __attribute_unused__ to suppress warnings about functions being unused or
+ * __attribute_used__ to ensure code is emitted when it is referenced only in
+ * inline assembly.
+ */
+#define __attribute_unused__ __attribute__((unused))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]