__attribute__
__attribute__ 的常见用途
__attribute__ 的常见用途void cleanup_function(int *p) { printf("Cleaning up!\n"); *p = 0; } void example() { int x __attribute__((cleanup(cleanup_function))) = 10; // 作用域结束时会调用 cleanup_function(&x) }int old_function() __attribute__((deprecated));struct __attribute__((aligned(16))) AlignedStruct { int data[4]; };void exit_now() __attribute__((noreturn));void my_printf(const char *format, ...) __attribute__((format(printf, 1, 2)));
语法
Last updated