Re: best practice to handle unused variables depending on macros

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

 



On Mon, Feb 6, 2012 at 18:34, Jonathan Wakely <jwakely.gcc@xxxxxxxxx> wrote:
> On 6 February 2012 16:47, Mathieu Lacage wrote:
>>
>> Some of my collegues have started to add #ifdefs here and there in our
>> main code to handle these problems as they come. Others have been
>> advocating the use of macros that mark the problematic variables as
>> unused.
>
> That would be my choice:
>
> int __attribute__((unused)) var =
> some_function_whose_return_value_is_used_only_by_assert_macro();

Right. My collegues want to wrap that in a macro. Bwaaah.

> You could define the assert macro to do (void)sizeof(a) which would
> not evaluate the expression but which does count as "using" variables
> in the expression with current GCC (though don't assume GCC won't get
> smarter and warn about it in future)

Out of curiosity, would (void)sizeof(a) work with non-gcc compilers ?

Mathieu
-- 
Mathieu Lacage <mathieu.lacage@xxxxxxxxx>


[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