4.5.8. __attribute__((unused))
通常,如果声明了某个变量,但从未对其进行引用,编译器将发出警告。 此属性指示编译器您预计不会使用某个变量,并指示它在未使用该变量时不要发出警告。
Note
此变量属性是 ARM 编译器支持的 GNU 编译器扩展。
void Variable_Attributes_unused_0()
{
static int aStatic =0;
int aUnused __attribute__ ((unused));
int bUnused;
aStatic++;
}
在此示例中,编译器发出已声明但从未引用 bUnused
的警告,但不会发出有关 aUnused
的警告。