jmasterx
jmasterx

Reputation: 54103

Automated inlining for VC++?

Is there a way to tell the compiler to inline wherever it sees it to be useful? I thought it did this by default, but adding a few inline to my game loop functions improved performance by a good 30%.

Thanks

Upvotes: 2

Views: 141

Answers (3)

Seth
Seth

Reputation: 46413

Visual C++ will do auto inline expansion if you tell it to, via the /Ob2 switch (but only if optimizations are turned on, e.g., /O2).

It could be that this was turned off, or perhaps the compiler isn't as aggressive at inlining as you want. In the latter case, use the inline keyword (which you have done :D).

Upvotes: 2

Ben Voigt
Ben Voigt

Reputation: 283614

The /Ob option

Note that the compiler can't auto-inline functions across compilation units unless you use Whole Program Optimization (/GL).

Upvotes: 3

Maister
Maister

Reputation: 5054

The compiler will generally inline functions if it will seem to boost performance, however, it might avoid this if you don't enable optimizations (e.g debug mode). If you enable optimizations, it should probably inline for you.

Upvotes: 1

Related Questions