Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inline functions in debug build (Visual C++ 2008)

The game engine I am working with is too slow in the debug build and is impossible to debug the game. One of the things I would like is for the compiler to inline small functions (especially in Vector/Matrix and container classes). This may or may not speed up the game in debug build. Before profiling heavily and trying to figure out bottlenecks I thought I would try this first as I would have to do minimal work and the results may be promising.

So, is there a way to get the Visual C++ compiler to inline functions in debug builds?

like image 698
Samaursa Avatar asked Sep 22 '11 14:09

Samaursa


2 Answers

Project options -> C/C++ -> Optimization -> Inline Function Expansion. Turn this to /Ob2. Do this in your Debug configuration.

In Release, inline function expansion is implied by other optimization settings, so even though by default all configurations say "Default" for the setting, the behavior is indeed different.

I believe Debug builds should have inline expansion behavior the same as release; there's really no reason not to.

http://msdn.microsoft.com/en-us/library/47238hez.aspx

like image 133
tenfour Avatar answered Sep 24 '22 08:09

tenfour


You're confusing two compiler options. /O influences optimization, including inlining. /ZI creates the PDB file for debugging. They can be set independently.

It may be useful to clone the "Debug" configuration, though, and create a "Debug-optimized" configuration with both /O1 and /ZI.

like image 23
MSalters Avatar answered Sep 20 '22 08:09

MSalters