Re: linux-6.12-rc1/drivers/iio/imu/bmi323/bmi323_core.c:133: Array contents defined but not used ?

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

 



On 30/09/2024 22:26, Nathan Chancellor wrote:
> Hi Javier,
> 
> On Mon, Sep 30, 2024 at 06:50:14PM +0200, Javier Carrasco wrote:
>> But if that wasn't the case, and since you can't use sizeof(<type>),
>> should it be marked with __maybe_unused / __attribute__((unused)) even
>> though it's known in advance that it won't be used, or at least that its
>> use will be to get its size?
> 
> Correct.
> 
>> Is it then just to silence the warning, or does it have other
>> implications? Thanks again!
> 
> Yes, the use of the unused attribute would just be to silence the
> warning; the variable would still not be emitted in the final binary.
> clang's behavior matches GCC's (aside from the special warning):
> 
> https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute
> 
> If the variable needed to be emitted in the object file,
> __attribute__((used)) would need to be used, which explicitly has code
> generation implications:
> 
> https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute
> 
> A contrived example:
> 
> https://godbolt.org/z/oGGbqK98o
> 
> Cheers,
> Nathan

Thanks a lot for spoon-feeding it to me :)

Best regards,
Javier Carrasco




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux