Controlling Optimization Levels

dougbinks edited this page Sep 8, 2014 · 1 revision

The CompileOptions.h header defines the following optimization enumberation:

enum RCppOptimizationLevel
{
    RCCPPOPTIMIZATIONLEVEL_DEFAULT = 0,     // RCCPPOPTIMIZATIONLEVEL_DEBUG in DEBUG, RCCPPOPTIMIZATIONLEVEL_PERF in release. This is the default state.
    RCCPPOPTIMIZATIONLEVEL_DEBUG,           // Low optimization, improve debug experiece. Default in DEBUG
    RCCPPOPTIMIZATIONLEVEL_PERF,            // Optimization for performance, debug experience may suffer. Default in RELEASE
    RCCPPOPTIMIZATIONLEVEL_NOT_SET,         // No optimization set in compile, so either underlying compiler default or set through SetAdditionalCompileOptions
};

These can be set via the IRuntimeObjectSystem::SetOptimizationLevel function for projects. The RCCPPOPTIMIZATIONLEVEL_DEFAULT is equivalent to RCCPPOPTIMIZATIONLEVEL_DEBUG in debug builds, and RCCPPOPTIMIZATIONLEVEL_PERF in release. Setting the level to RCCPPOPTIMIZATIONLEVEL_DEBUG in a release build can be useful to aid debugging once an issue has been found or a complex level loaded for example. The RCCPPOPTIMIZATIONLEVEL_NOT_SET is useful where the developer wants finer control of settings through Setting Additional Compile and Link Options.