Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main() {
- printf("before declarations\n");
- void defer1() { printf("defer1\n"); };
- void defer2() { printf("defer2\n"); };
- void defer3() { printf("defer3\n"); };
- void defer4() { printf("defer4\n"); };
- printf("after declarations\n");
- int var1 __attribute__((cleanup(defer1)));
- int var2 __attribute__((cleanup(defer2)));
- printf("before inner scope\n");
- {
- printf("inner scrope begin\n");
- int var3 __attribute__((cleanup(defer3)));
- printf("inner scope end\n");
- }
- printf("after inner scope\n");
- printf("before loop\n");
- for (int i = 0; i < 2; ++i) {
- printf("loop iter begin: %d\n", i);
- int var4 __attribute__((cleanup(defer4)));
- printf("loop iter end: %d\n", i);
- }
- printf("after loop\n");
- printf("function end\n");
- return 0;
- }
Add Comment
Please, Sign In to add comment