This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: How to clear unused variable warnings created by static assert?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Martin Sebor <msebor at gmail dot com>
- Cc: "gcc-help at gcc dot gnu dot org" <gcc-help at gcc dot gnu dot org>
- Date: Thu, 23 Jul 2015 11:14:39 -0400
- Subject: Re: How to clear unused variable warnings created by static assert?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8mfb5Q1rTecQr2wZtq_y=0V1wt9H1ud_sp=pQgmtmuYfA at mail dot gmail dot com> <55B1033D dot 50900 at gmail dot com>
- Reply-to: noloader at gmail dot com
> 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.
Jeff