How to clear unused variable warnings created by static assert?
Jeffrey Walton
noloader@gmail.com
Thu Jul 23 15:32:00 GMT 2015
On Thu, Jul 23, 2015 at 11:14 AM, Jeffrey Walton <noloader@gmail.com> wrote:
>> But perhaps the simplest and least intrusive approach, if you
>> can't use static_assert, is to annotate the unused variable with
>> attribute unused:
>>
>> #define COMPILE_ASSERT_INSTANCE(assertion, instance) \
>> static CompileAssert<(assertion)> \
>> ASSERT_JOIN(assert_, instance) __attribute__ ((unused))
>>
>
> I like the sound of this one. To pull it off, I need to ensure the
> gear that claims to be GCC (by faking __GNUC__), and GCC itself, can
> handle it.
>
> When did GCC add '__attribute__ ((unused))'? We still have GCC 3.x
> users (IIRC), so we can't break things for them. There is a shinny
> side to the penny: we don't have to support GCC 2.95.
>
It looks like __ attribute__ ((unused)) is available in 2.95:
https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#SEC84.
I'll take that as a win since it predates our minimum. Thanks for the
suggestion.
Jeff
More information about the Gcc-help
mailing list