Re: [PATCH] pktgen: avoid unused-const-variable warning
From: Paolo Abeni
Date: Thu Feb 27 2025 - 09:43:50 EST
On 2/27/25 3:21 PM, Peter Seiderer wrote:
> On Thu, 27 Feb 2025 12:35:45 +0100, Paolo Abeni <pabeni@xxxxxxxxxx> wrote:
>> I think the unused define is preferable; I think pre-processor defines
>> are cheaper than static const.
>
> In which regards cheaper (out of interest)?
>
> Both (with and without static) produce the same code see e.g.
>
> https://godbolt.org/z/Tsr1jM45r
> https://godbolt.org/z/6sr1o8da3
I must admit I was unsure the compiler would always optimize out the
constant.
I guess the macro could still produce shorter build time (by a few clock
cycles, nothing measurable ;), so in the end it boils down again to a
personal preference.
Cheers,
Paolo