On 2026-02-23 18:23:44, Peter Barada wrote:
> I'd like to add "-Wextra" to tease out more warnings, but the current
> UNUSED() definition then causes the following(among others):
> 
> chip/stm32_irq.c: In function 'stm32_nmi':
> chip/stm32_irq.c:175:12: warning: the address of 'irq' will always evaluate 
> as 'true' [-Waddress]
>  175 |  ((void)(1 || &(
>      |            ^~
> 
> Would there be any issue if I redefined UNUSED() to cast its arg to void
> instead (or at least for just gcc compilers)?

> #    define UNUSED(a) ((void)(1 || &(a)))

Now that's a strange way to make argument as unused I must say. I suppose that
may be a hack for some obscure compilers maybe? In GCC and Clang just voiding
the argument should be all you need. I think defining it like this should be
fine, for backward compatibility. Unless we can get rationale behind this ;)

        #  ifndef UNUSED
        #    if defined(__clang__) || defined(__GNUC__)
        #      define UNUSED(a) ((void)a)
        #    else
        #      define UNUSED(a) ((void)(1 || &(a)))
        #    endif
        #  endif

Attachment: signature.asc
Description: PGP signature

Reply via email to