[lkml]   [2007]   [May]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[patch 01/10] compiler: define __attribute_unused__
    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

    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 <>
    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
    More majordomo info at
    Please read the FAQ at
     \ /
      Last update: 2007-05-02 06:31    [W:0.021 / U:16.560 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site