From: Willy Tarreau Date: Mon, 20 Nov 2017 20:22:17 +0000 (+0100) Subject: BUILD: compiler: add a new type modifier __maybe_unused X-Git-Tag: v1.8.0~81 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dbd25fc75ad2e409c7347289d245e10521cc240a;p=thirdparty%2Fhaproxy.git BUILD: compiler: add a new type modifier __maybe_unused While gcc only emits warnings about unused static functions, Clang also emits such a warning when the functions are inlined. This is a bit annoying at certain places where functions are provided to manipulate multiple data types and are not yet used. Let's have a type modifier "__maybe_unused" which sets the "unused" attribute like the Linux kernel does. It's elegant as it allows the code author to indicate that it knows that this element might be unused. It works on variables as well, which is convenient to remove ifdefs around local variables in certain functions, but doesn't work on labels. --- diff --git a/include/common/compiler.h b/include/common/compiler.h index ee7744c9fd..a13aad5c62 100644 --- a/include/common/compiler.h +++ b/include/common/compiler.h @@ -77,6 +77,10 @@ #endif #endif +/* silence the "unused" warnings without having to place painful #ifdefs. + * For use with variables or functions. + */ +#define __maybe_unused __attribute__((unused)) /* * Gcc >= 3 provides the ability for the programme to give hints to the