The GNU compiler (GCC) provides a number of C language extensions that the compiler uses to generate more efficient machine code.
inline functions
Static int foo (void/** /}
Avoid inline
int foo (void/*... ) */ }
Pure function
int foo (int/* /}
The return value is only affected by function arguments or nonvolatile global variables.
Constant function
__ATTRIBUTE__ ((constint foo (int/* ... */ }
The constant function is a strict pure function. The constant function cannot access the global variable, and the parameter cannot be a pointer type. Therefore, the return value of a constant function is only related to the value of the parameter passed by the value.
function with no return value
void foo (int/* ...) */ }
Functions that allocate memory
__attribute__ (mallocvoid *copy ( ) {int); return malloc (ten);}
Forcing callers to check the return value
1#include <stdio.h>2 3__attribute__ ((Warn_unused_result))intfoo ()4 {5 return 0;6 }7 8 intMain ()9 {Ten foo (); One return 0; A}
Identify the function as "Deprecated (deprecated)"
void foo (void/*... ) */ }
Identify the function as being used
Static void foo (void/*... ) */ }
Identifies a function or parameter as unused
int foo (int/* ...) */}
Compact Storage (pack) for structures
struct __attribute__ ((packed)) Foo {...};
The packed property tells the compiler that a type or variable should be stored in memory compactly, using as little space as possible, and may not rely on alignment requirements. If you specify this property on a struct (struct) or union (union), you need to store all the variables compactly. If you specify this property only for a variable, only the specific variable is stored compactly.
GCC Extensions for C languages