Re: How to clear unused variable warnings created by static assert?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I've just filled in the unsubscribe form at
https://gcc.gnu.org/lists.html#subscribe for both papa@xxxxxxxxxxx and
arbolone@xxxxxxxxxx since it's apparently too difficult for some
people to manage on their own.

On 23 July 2015 at 17:45, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
> And I've explained how to unsubscribe many times:
>
> https://gcc.gnu.org/ml/gcc-help/2015-07/msg00043.html
>
>
>
> On 23 July 2015 at 15:47,  <papa@xxxxxxxxxxx> wrote:
>> I have unsubscribe many, many times, but you have a serious problem
>> receiving the message. I am papa@xxxxxxxxxxx, please, please unsubscribe me.
>> This mailing list is useless to me, if this continues I will take more
>> offensive action, which is something both of us are trying to avoid.
>>
>> If you are reading this email, but you are not gcc-help administrator,
>> please, please, forward this email to the administrator or simple reply to
>> all. GCC-help should know what to do with this message. Thanks in advance
>> and please forgive me for any inconvenience.
>>
>> -----Original Message----- From: Jeffrey Walton
>> Sent: Thursday, July 23, 2015 8:50 AM
>> To: gcc-help@xxxxxxxxxxx
>> Subject: How to clear unused variable warnings created by static assert?
>>
>>
>> Our project has a static assert.  Its creating a noisy output at -Wall
>> and above. We attempted to manage it with a GCC diagnostic block, but
>> its not quite meeting expectations. The static assert creates a bunch
>> of unused variable warnings.
>>
>> We have a UNUSED macro that casts to a void (its the only portable way
>> I know to clear an unused warning), but we don't have a variable name
>> to use with it.
>>
>> How can we clear a warning like `unused variable 'assert_26'
>> [-Wunused-variable]|`?
>>
>> **********
>> Here's the static assert:
>>
>> template <bool b>
>> struct CompileAssert
>> {
>>    static char dummy[2*b-1];
>> };
>>
>> #define COMPILE_ASSERT(assertion) COMPILE_ASSERT_INSTANCE(assertion,
>> __LINE__)
>> #define COMPILE_ASSERT_INSTANCE(assertion, instance) static
>> CompileAssert<(assertion)> ASSERT_JOIN(assert_, instance)
>> #define ASSERT_JOIN(X, Y) DO_ASSERT_JOIN(X, Y)
>> #define DO_ASSERT_JOIN(X, Y) X##Y
>>
>> **********
>> Here's how we try to manage it in one of out header files:
>>
>> #ifndef FOO_BAR
>> #define FOO_BAR
>>
>> #define GCC_OPTIMIZE_AWARE ((__GNUC__ > 4 || (__GNUC__ == 4 &&
>> __GNUC_MINOR__ >= 7)) || defined(__clang__))
>>
>> #if GCC_DIAGNOSTIC_AWARE
>> # pragma GCC diagnostic push
>> # pragma GCC diagnostic ignored "-Wunused-value"
>> # pragma GCC diagnostic ignored "-Wunused-variable"
>> #endif
>>
>> ....
>> COMPILE_ASSERT(foo == bar);
>>
>> #if GCC_DIAGNOSTIC_AWARE
>> # pragma GCC diagnostic pop
>> #endif
>>
>> #endif // FOO_BAR
>>
>> **********
>>
>> Users include the header file, so we have no control over which
>> options they place on the command line.
>>
>> Here's an example of the warning it generates with -Wall and GCC 4.8
>> (even when guarded like above):
>>
>>    unused variable 'assert_26' [-Wunused-variable]|



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux