The __attribute__ keyword enables you to specify special attributes of variables or structure fields, functions, and types. The keyword format is either:
__attribute__ ((attribute1, attribute2, ...))
__attribute__ ((__attribute1__, __attribute2__, ...))
For example:
void * Function_Attributes_malloc_0(int b) __attribute__ ((malloc));
static int b __attribute__ ((__unused__));
Table 9 summarizes the available function attributes.
Table 9. Function attributes supported by the compiler and their equivalents
| Function attribute | non-attribute equivalent |
|---|
__attribute__((alias)) | - |
__attribute__((always_inline)) | __forceinline |
__attribute__((const)) | __pure |
__attribute__((constructor[(priority)])) | - |
__attribute__((deprecated)) | - |
__attribute__((destructor[(priority)])) | - |
__attribute__((format_arg(string-index))) | - |
__attribute__((malloc)) | - |
__attribute__((noinline)) | __declspec(noinline) |
__attribute__((no_instrument_function)) | - |
__attribute__((nomerge)) | - |
__attribute__((nonnull)) | - |
__attribute__((noreturn)) | __declspec(noreturn)) |
__attribute__((notailcall)) | - |
__attribute__((pcs("calling_convention"))) | - |
__attribute__((pure)) | - |
__attribute__((section("name"))) | - |
__attribute__((unused)) | - |
__attribute__((used)) | - |
__attribute__((visibility("visibility_type"))) | - |
__attribute__((weak)) | __weak |
__attribute__((weakref("target"))) | - |