You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. Use [[maybe_unused]] C++17 attribute instead of GCC/Clang __attribute__((unused))
The attribute should appear immediately AFTER the name of the parameter,
before any array dimensions (this should fix ARM build issue where old-style
__attribute__((unused)) worked after an array dimension but [[maybe_unused]]
did not work).
The UNUSED() macro is almost always called with only the name of the function
parameter, without any type information, so the [[maybe_unused]] attribute
cannot be placed BEFORE the macro argument, where it would be ignored as not
applying to the immediately preceding type. For it to appear BEFORE the
parameter name, it would need to appear before the type as well, and then all
of the calls to UNUSED() would need to be modified to look something like:
UNUSED(const std::string& name)
instead of:
const std::string& UNUSED(name)
Although cppreference.com is scant on details, my research has found that
attributes applying to specific identifiers must appear immediately AFTER
the name. The old __attribute__((unused)) GCC/Clang attribute appeared
after the name, and so does [[maybe_unused]] with this change.
2. Remove UNUSED() macro used in function declarations which are not
definitions, since the compiler does not check whether function parameters
are actually used in declarations, only in definitions.
3. Remove UNUSED() macro that is used where the parameter is not unused
anymore.
0 commit comments