This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: explaination of trampoline



The c code for which i'm observing the effect is as follows.

int foo(int (*f)()){
       (*f)();
}
main(){
       int g(){printf("hello");}
       foo(g);
}

This one does not need a trampoline, because there would not be any difference if int g() was not a nested function -- g() has no static chain argument. Try this one instead:


int foo(int (*f)()){
       (*f)();
}
main(int argc, char **argv){
       int g(){printf("hello, argc=%d\n", argc);}
       foo(g);
}

You will see trampolines in all their beauty.

Paolo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]