-
Visual C++ Compiler Options
Posted on March 16th, 2010 1 commentIt is important to understand your tools. So when I went looking at the documentation for the compiler, I was surprised to see that it was missing a lot of information on the defaults the compiler uses.
I’ve also always been uncomfortable with the way the compilers get a lot of their state from environment variables. I think it is important that given a build script and the same code, it should always build the same binaries and debug output. This assumption can be broken by small differences in the configuration of the machine building the code.
In order to create a reproducible build, we have to start somewhere. Let’s start by looking at the options for the compiler. What are the default compiler settings if no options are given? Unfortunately there is no definitive documentation. Given the lack of documentation, the rational thing to do would be to explicitly specify all the options.
Default Options
I did some research and found the default options for the compiler supplied with Visual Studio 2008, are:
cl default options (Equivalent to cl Hello.c)
cl /W1 /Ze/ Zp8 /ZB64 /Gs4096 /Ot /FoHello.obj /Fdvc90.pdb /GS /Ob0 /MT /ZM Hello.c- /W1, Sets warning level to 1
- /Ze, Turns on microsoft extensions to C and C++
- /ZB64, Sets maximum integral types to 64bits (Undocumented)
- /Zp8, Sets struct or class packing to 8 bytes
- /Gs4096, Causes stack probe code to be generated for functions with locals greater than 4096KB
- /Ot, Optimise for time rather than space
- /FoHello.obj, Name for object file output
- /Fdvc90.pdb, Name for pdb file generated by compiler
- /GS, Generate stack frame cookies
- /Ob0, Disable inline expansion
- /MT, Link to multithreaded static crt library
- /ZM, Sets the compiler to not completely finish processing a compilation unit (cpp/c file) before starting to process the next (undocumented)
Thanks to Geoff Chappell for providing the information I needed to find the default parameters. He has studied the compiler and figured out many of the compiler’s undocumented parameters. Here’s the information I used from his site: Initial CL.EXE options and Compulsory Options.


