Compiler Options

Though the official literature for CL.EXE does document most command-line options, undocumented options do exist and some of the documented options are arguably not documented well. In the list below of CL command-line options recognised by version 13.00.9466, those that are omitted from the product documentation’s page Compiler Options Listed Alphabetically are highlighted yellow. Some of these highlighted options are semi-documented, or at least their existence is semi-documented. For instance, they are listed in the output of the cl /? command, or are used in some batch file or makefile that Microsoft publishes either with Visual C++ or with some software development kit. For a few of the highlighted options, Microsoft does publish formal documentation—but for some other of Microsoft’s C/C++ products!

The alternative documentation attempted for each option assumes familiarity with all the notes on the CL command line and especially with the common syntax of CL options.

Only for very few options is more attempted than just the syntax. I’m sorry, but there are very many compiler options. To discover their behaviour independently of Microsoft, and write it up, can never be more than a work in progress, particularly when that work is the intermittent output of one person’s study, and may easily amount to nothing but a record of some vague intention that got put aside due to lack of interest, support, etc. If you are disappointed by the coverage, express your encouragement in an email.

The options listed below are all those that CL recognises. Anything else causes warning D4002. Many more compiler options exist, but they are listed separately, as C1XX options and C2 options, because they are not accepted by CL but must instead be passed indirectly to the relevant compiler module via the CL /d1 and /d2 options.

Unsupported Options

A few more options are dismissed with the same warning (D4002) as if unrecognised, but are more precisely described as recognised but unsupported.

These options are all meaningful to the last of Microsoft’s C/C++ compilers for 16-bit code, namely Microsoft Visual C++ 1.52 for DOS and Windows, and perhaps to earlier versions also. That they are recognised by CL in version 13.00.9466 is presumably for backwards compatibility, so that old but now meaningless options (perhaps generated by old makefiles) cause a warning rather than prevent the build from proceeding. For instance, were /FP left unrecognised, a once meaningful but now harmlessly meaningless /FPi87 would be interpreted as a /F option whose argument “Pi87” would be an error (D2021).

Internal Options

If only for completeness, note that yet a few more options exist that CL dismisses as unrecognised, with the same warning (D4002), when given on any command line that can be supplied by a user, but which CL recognises in its own hard-coded command-line of initial options.

Of these, only /dos, /f, /il and /pc actually do appear in the initial options that are hard-coded in the CL.EXE for Microsoft Visual C++.