Unified · Split
| @@ -1,6 +1,13 @@ | ||
| 1 | −#include <stdio.h> | |
| 1 | +extern int printf(const char*, ...); | |
| 2 | 2 | |
| 3 | −struct fred | |
| 3 | +struct fred; | |
| 4 | + | |
| 5 | +void fred$(struct fred* this) | |
| 6 | +{ | |
| 7 | + printf("~fred()\n"); | |
| 8 | +} | |
| 9 | + | |
| 10 | +struct __attribute__((__cleanup__(fred$))) fred | |
| 4 | 11 | { |
| 5 | 12 | int boris; |
| 6 | 13 | int natasha; |
| @@ -8,7 +15,7 @@ struct fred · 1 unmodified line | ||
| 8 | 15 | |
| 9 | 16 | int main() |
| 10 | 17 | { |
| 11 | − struct fred bloggs; | |
| 18 | + struct fred __attribute__((__cleanup__(fred$))) bloggs; | |
| 12 | 19 | |
| 13 | 20 | bloggs.boris = 12; |
| 14 | 21 | bloggs.natasha = 34; |
| @@ -1,6 +1,8 @@ | ||
| 1 | +03_struct.c:14: warning: attribute '__cleanup__' ignored on type | |
| 1 | 2 | 12 |
| 2 | 3 | 34 |
| 3 | 4 | 12 |
| 4 | 5 | 34 |
| 5 | 6 | 56 |
| 6 | 7 | 78 |
| 8 | +~fred() | |