#include #ifdef BAD /* Some gcc versions generate a call to this function in trampolines for nested functions. */ void __enable_execute_stack (void *addr __attribute__ ((unused))) { } #endif int apply(void (*hook) (int *)) { int a = 0; hook(&a); hook(&a); return a; } int main (int argc, char *argv[]) { /* static */ int j = 5; int res; void hook(int *n) { *n = *n + j; j--; } res = apply(hook); printf("result: %d, j=%d\n", res, j); return 0; }