1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| struct __main_block_impl_0 { struct __block_impl impl; struct __main_block_desc_0* Desc; // 使用自动变量被当做成员变量追加到__main_block_impl_0结构体中 int a; const char *fmt;
__main_block_impl_0(void *fp, struct __main_block_desc_0 *desc, int _a, const char *_fmt, int flags=0) : a(_a), fmt(_fmt) { impl.isa = &_NSConcreteStackBlock; impl.Flags = flags; impl.FuncPtr = fp; Desc = desc; } }; static void __main_block_func_0(struct __main_block_impl_0 *__cself) { int a = __cself->a; // bound by copy const char *fmt = __cself->fmt; // bound by copy
printf("%d %s\n", a, fmt); }
static struct __main_block_desc_0 { size_t reserved; size_t Block_size; } __main_block_desc_0_DATA = { 0, sizeof(struct __main_block_impl_0)};
int main(int argc, char const *argv[]) { int a = 1; const char *fmt = "1"; void (*blk)(void) = ((void (*)())&__main_block_impl_0((void *)__main_block_func_0, &__main_block_desc_0_DATA, a, fmt)); return 0; }
|