This is the mail archive of the gcc-help@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]

a question about function inlining


Hello.

I know the GCC C++ compiler can inline often-called functions automatically
for performance reasons. I have to set the option -O3 for that. OK, but does
it do inlining even across libraries?

Say, I have a class like that:

class Test {
public:
	Test();
	~Test();
	void called_very_often();
};

Test::Test() {
}

Test::~Test() {
}

void Test::called_very_often() {
	// one or two statements are placed here
}

This class is compiled into a static library called Test.lib or libtest.a.
When I have a C++-Code like this:

int main(int argc, char** argv) {
	Test * t = new Test();
	[...]
	t->called_very_often();
	[...]
	delete t;
}

When compiled with -O3, are there chances that the GCC C++ compiler will
inline the member method called_very_often() of library class Test in main()
even though it's compiled externally and called via a pointer? If not, what
could I do to force that?

Many Thanks! :)

Best Regards
Chester Kollschen


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