Options Not Optional
By rchrd on Jan 07, 2009
Compiler options can be mysterious. They can have kind of a "don't go there" mystique about them. But actually they're there to help.
There are some things the compiler can't do without help from the programmer. So that's when the compiler designers say "let's leave it to the programmer and create an option". Options also accumulate with time, so that's why there are so many of them. Some are "legacy" options, needed for certain situations that rarely come up these days. But the rest are really quite useful, and can greatly improve the kind of code the compiler generates from your source.
There are compiler command-line options for various things, like code optimization levels and run-time performance, parallelization, numeric and floating-point issues, data alignment, debugging, performance profiling, target processor and instruction sets, source code conventions, output mode, linker and library choices, warning and error message filtering, and more. Choosing the right set of options to compile with can make a great difference on how your code performs on a variety of platforms.
Over the next couple of weeks I'll be taking a look at individual compiler options, dissecting them one at a time.
In the meantime, you can find a detailed list of Sun Studio 12 compiler options organized by function and source language here.