__attribute__((cleanup))
基本用法
#include <stdio.h>
void cleanup_int(void *p) {
int *i = (int *)p;
printf("Cleaning up: %d\n", *i);
}
int main() {
__attribute__((cleanup(cleanup_int))) int x = 10;
printf("Value of x: %d\n", x);
return 0;
}Value of x: 10
Cleaning up: 10编译器的处理方式
使用场景
注意事项
Last updated