O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compiler Optimization

There are two classes of argument flags for controlling optimization, which controls how the compiler generates machine code from your C code, as well as how it rewrites your code to behave more optimally. You can use -O with a number or letter to control the optimization level.

-O0

Do no optimizations.

-O1

Do some optimization (also what’s used if you use -O without a number).

-O2 and -O3

Use yet more aggressive optimization.

-Os

Optimize for size. It does the same optimizations as -O2 but doesn’t do function inlining.

Higher optimization levels can make code unstable as more and more mechanical operations happen to it, so be sure to test when changing levels. Sometimes failures that happen at higher optimization levels ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required