__attribute_unused__および_attribute_used__の役割

699 ワード

Linuxでは次のように定義されています.
#define __attribute_used__ __attribute__((__used__))

#define __attribute_unused__ __attribute__((__unused__))

gccマニュアルでは、unused:This attribute,attached to a function,means that the function is meant to be possibly unusedに関する解釈が見つかった.GCC will not produce a warning for this function.
関数または変数が使用されない可能性があることを示します.このプロパティは、コンパイラによる警告を回避します.used: This attribute, attached to a function, means that code must be emitted for the        function even if it appears that the function is not referenced. This is useful,        for example, when the function is referenced only in inline assembly.
このコードが役に立つことをコンパイラに説明すると、使用していない場合でもコンパイラは警告しません.