Skip to content

clang_nowarn_bfd_mark_unused

Tsukasa OI edited this page Sep 15, 2022 · 8 revisions

Clang: Remove/mark unused variables (bfd, binutils and gas)

Issue Solved

Clang generates a warning on "written but not read thereafter" varibles (-Wset-but-unused-variable), making the build failure.

We could just remove practically unused variables but instead I chose to keep some of them but with ATTRIBUTE_UNUSED. This is because such variables may have possible uses in the future.

Others are just removed.

ATTRIBUTE_UNUSED (__attribute__((unused))) marks a variable possibly unused and suppresses warnings about "written but not read thereafter" or just "unused" variables.

Note that it only means a variable is "possibly unused". Even if a variable with this attribute is "used", it's completely safe (removing the attribute when a variable is started to be used is definitely better, though).

Clone this wiki locally