Re: using inline functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Generally the compiler needs the information used with normal optimization
levels (-O) to be able to inline functions.

Thanks Michael, but -O, -O1 didn't work too. 

///////template class 
template<class typeData> 
class TEMP 
{ 
public: 
typeData data; 
inline int func1(){ return data; }
}; 

main() 
{... 
TEMP<int> a; 
printf("input:"); 
scanf("%d",&a.data); 

int b; 
b=a.func1(); 
b=a.func1(); 
b=a.func1(); 
b=a.func1(); 
printf("%d\n",a.data); 
...} 
/////// 
<-O1 -finline-functions> 
b=a.func1(); 
  58: 8d 45 fc             lea    0xfffffffc(%ebp),%eax 
  5b: 89 04 24             mov    %eax,(%esp) 
  5e: e8 00 00 00 00       call   63 <_main+0x63> 
printf("%d\n",a.data); 
  63: 8b 45 fc             mov    0xfffffffc(%ebp),%eax 
  66: 89 44 24 04           mov    %eax,0x4(%esp) 
  6a: c7 04 24 0a 00 00 00 movl   $0xa,(%esp) 
  71: e8 00 00 00 00       call   76 <_main+0x76> 

<-O2 -finline-functions> 
int b; 
b=a.func1(); 
b=a.func1(); 
b=a.func1(); 
b=a.func1(); 
printf("%d\n",a.data); 
  37: c7 04 24 0a 00 00 00 movl   $0xa,(%esp) 
  3e: 8b 45 fc             mov    0xfffffffc(%ebp),%eax 
  41: 89 44 24 04           mov    %eax,0x4(%esp) 
  45: e8 00 00 00 00       call   4a <_main+0x4a> 

<-O3> 
int b; 
b=a.func1(); 
b=a.func1(); 
b=a.func1(); 
b=a.func1(); 
printf("%d\n",a.data); 
  37: c7 04 24 0a 00 00 00 movl   $0xa,(%esp) 
  3e: 8b 45 fc             mov    0xfffffffc(%ebp),%eax 
  41: 89 44 24 04           mov    %eax,0x4(%esp) 
  45: e8 00 00 00 00       call   4a <_main+0x4a>
test.cpp
-- 
View this message in context: http://www.nabble.com/using-inline-functions-tp18248125p18253594.html
Sent from the gcc - Help mailing list archive at Nabble.com.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux