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: Oleg Endo <oleg dot endo at t-online dot de>
- To: noloader 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 23:48:05 +0900
- 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> <55B0FB68 dot 9020704 at gmail dot com> <CAH8yC8=KWfrYPJnr-wcEDTgAG27jT+qe-=R8U36z56HitiiW_A at mail dot gmail dot com>
On 23 Jul 2015, at 23:40, Jeffrey Walton <noloader@gmail.com> wrote:
>> Why don't you simply use a C++ static_assert?
>>
>> static_assert(foo==bar, "foo should have been bar");
>
> C++ 03.
>
> Jeff
You could try the typedef variant of the C++98 static assert and attach an attribute unused to the typedef.
See also:
http://stackoverflow.com/questions/6954284/why-prefer-template-based-static-assert-over-typedef-based-static-assert
http://stackoverflow.com/questions/386220/how-can-i-hide-defined-but-not-used-warnings-in-gcc
Cheers,
Oleg