Consider the follwing C++ code:
#include <iostream>
using namespace std;
class A
{
int a;
public:
A();
void f();
};
A::A()
{
cout<<"Constructor"<<endl;
}
inline void A::f()
{
cout << "hello\n";
}
int main()
{
A a;
a.f();
a.f();
a.f();
return 0;
}
Here the function f is made inline by me. Now I ran the size command to find out the size of the text section. I got the following output:
text data bss dec hex filename
2148 312 144 2604 a2c ./1
Now I made the function f non-inline by removing the inline keyword from its definition. The I again ran the size command:
text data bss dec hex filename
2148 312 144 2604 a2c ./1
So, the size of the text section is same in both cases, although I expected the size to be greater in case of f being inline as its call is simply replaced by the code in case of inline.
So, what could be the reason for this? Is there any example where the size will change?