The compiler implements the following attributes (__attribute__ ((keyword)) ) for compatibility. Spelling the attribute keyword within double underscores, __keyword__, is also accepted.
Makes a name an alias for a declared function or variable name.
Roughly equivalent to #pragma align. Generates a warning and is ignored if used on variable length arrays.
Equivalent to #pragma inline and -xinline.
Causes the function specified with the attribute to be executed when the associated variable goes out of scope (exits the block in which it is declared). It can be applied only to auto function scope (local) variables, and cannot be applied to parameters or variables with static storage duration. The function must take one parameter, a pointer to a type compatible with the variable. The return value of the function (if any) is ignored. It is undefined what happens if the cleanup function does not return normally.
The common attribute requests the compiler to place a variable in "common" storage, which is where a tentative definition of a variable is placed. The nocommon attribute requests the opposite, create a definition initialized to 0. These attributes override the default chosen by the -fno-common and -fcommon flags respectively.
Equivalent to #pragma no_side_effect.
Equivalent to #pragma init, except the constructor will only be called once.
Results in a warning if the variable or function is used anywhere in the source file. The optional argument msg must be a string and will be included in the warning message if issued.
Equivalent to #pragma fini.
Equivalent to #pragma returns_new_memory.
Equivalent to #pragma no_inline and -xinline.
Equivalent to #pragma does_not_return.
Equivalent to #pragma does_not_write_global_data.
Equivalent to #pragma pack(), except when applied to an enum type, where it tells the compiler to set the type of an enum to the smallest type capable of holding all the enumerator values. A signed type is used if and only if at least one of the enumerators has a negative value. Ultimately, a packed enum can become type signed char, unsigned char, signed short or unsigned short, depending on the enumerator values used.
Equivalent to #pragma unknown_control_flow.
Places a global variable (or function) in a named section, instead of the sections .bss or .data. Make sure to initialize any global variable placed in a named section to avoid multiply defined error messages from the linker.
Sets the thread-local storage model. The tls_model argument should be one of global-dynamic, local-dynamic, initial-exec, or local-exec.
Indicates that a variable or a type name (created using typedef) represents a vector.
Provides linker scoping as described in Linker Scoping Specifiers. Syntax is: __attribute__((visibility(“visibility-type”))), where visibility-type is one of the following:
Same as __global linker scoping.
Same as __hidden linker scoping.
Same as __symbolic linker scoping.
Equivalent to #pragma weak.
The predefined function-like macro,
evaluates to 1 if attr is a supported attribute. It evaluates to 0 otherwise. Example usage:
#ifndef __has_attribute // if we don't have __has_attribute, ignore it #define __has_attribute(x) 0 #endif #if __has_attribute(deprecated) #define DEPRECATED __attribute__((deprecated)) #else #define DEPRECATED // attribute "deprecated" not available #endif void DEPRECATED old_func(int); // use the attribute if available