When I try it with -O1, it does inline the pointer as well... Sorry for my spams. Thanks, Yavuz ---------------------------------------- > From: yavuzyetim@xxxxxxxxxxx > To: gcc-help@xxxxxxxxxxx > Subject: FW: Inlining function pointers > Date: Wed, 26 Aug 2009 14:34:40 +0000 > > > > > ---------------------------------------- >> From: yavuzyetim@xxxxxxxxxxx >> To: eljay@xxxxxxxxx >> Subject: RE: Inlining function pointers >> Date: Wed, 26 Aug 2009 14:34:09 +0000 >> >> >> Sorry, my mistake, so I tried the below: It does inline the regular call but why can't it inline the function pointer? It knows which function this pointer is pointing to beforehand. So shouldn't it inline it? >> >> #include >> >> static inline void print_stuff() __attribute__((always_inline)); >> static inline void print_stuff() >> { >> printf("yavuz"); >> } >> static inline void call_func(void (*my_func)()) __attribute__((always_inline)); >> static inline void call_func(void (*my_func)()) { >> my_func(); >> } >> >> int main() { >> call_func(print_stuff); >> } >> >> and the result is: >> trash$gcc -S den.c >> trash$more den.s >> .file "den.c" >> .text >> .globl main >> .type main, @function >> main: >> leal 4(%esp), %ecx >> andl $-16, %esp >> pushl -4(%ecx) >> pushl %ebp >> movl %esp, %ebp >> pushl %ecx >> subl $20, %esp >> movl $print_stuff, -8(%ebp) >> movl -8(%ebp), %eax >> call *%eax >> addl $20, %esp >> popl %ecx >> popl %ebp >> leal -4(%ecx), %esp >> ret >> .size main, .-main >> .section .rodata >> .LC0: >> .string "yavuz" >> .text >> .type print_stuff, @function >> print_stuff: >> pushl %ebp >> movl %esp, %ebp >> subl $8, %esp >> movl $.LC0, (%esp) >> call printf >> leave >> ret >> .size print_stuff, .-print_stuff >> .ident "GCC: (Ubuntu 4.3.3-5ubuntu4) 4.3.3" >> .section .note.GNU-stack,"",@progbits >> >> >> >> ---------------------------------------- >>> From: eljay@xxxxxxxxx >>> To: yavuzyetim@xxxxxxxxxxx >>> Date: Wed, 26 Aug 2009 07:30:35 -0700 >>> Subject: Re: Inlining function pointers >>> >>> Hi yavuz, >>> >>>> trash$gcc -finline-functions -S den.c >>> >>> That won't result in the functions to be inlined. >>> >>> You have to enable optimization as well: -O1 -finline-functions >>> >>> Sincerely, >>> --Eljay >>> >> >> _________________________________________________________________ >> Windows Live: Make it easier for your friends to see what you’re up to on Facebook. >> http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_facebook:082009 > > _________________________________________________________________ > Get back to school stuff for them and cashback for you. > http://www.bing.com/cashback?form=MSHYCB&publ=WLHMTAG&crea=TEXT_MSHYCB_BackToSchool_Cashback_BTSCashback_1x1 _________________________________________________________________ Windows Live: Keep your friends up to date with what you do online. http://windowslive.com/Campaign/SocialNetworking?ocid=PID23285::T:WLMTAGL:ON:WL:en-US:SI_SB_online:082009