CL Command-Line Errors

Errors issued by the CL.EXE program are all fatal: after writing the error message, CL terminates (with exit code 2). The general form of the whole error message is

cl : Command line error Dnumber : text

The message is written to standard error. Note however, that unless CL detects /E, /EP, /P or /Zg on its command line, it eventually duplicates standard output as standard error. In practice then, errors that occur sufficiently early (most notably during command-line analysis) are reported to whatever file or device CL was given as standard error, but errors that occur later are reported to whatever file or device CL was given as standard output. This behaviour seems to be undocumented, but knowledge of it is important if depending on command-line redirection for capturing CL error messages to a file.

The table below lists the command-line errors that CL is known to be capable of issuing in version 13.00.9466. Text for each error message is reproduced from the corresponding resource string in the executable, with placeholders resolved as much as possible in the style of the product documentation.

Error numbers that the product documentation does not list among the Command-Line Errors D2000 Through D4028 are highlighted yellow. One error, D2028, that is listed by the product documentation does not appear below, in the belief that CL has no code for producing it.

Error Message Text
D2000 UNKNOWN COMMAND-LINE ERROR
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
D2003 missing source filename
D2004 '/option' requires an argument
D2016 '/option1' and '/option2' command-line options are incompatible
D2018 cannot create linker response file
D2021 invalid numeric argument '/option'
D2022 cannot open 'filename'
D2027 cannot execute 'component'
D2029 cannot execute 'component' out of environment memory
D2030 INTERNAL COMPILER ERROR in 'component'
    Please choose the Technical Support command on the Visual C++
    Help menu, or open the Technical Support help file for more information
D2034 error reading 'filename'
D2035 response files nested too deeply
D2036 '/option' not allowed with multiple source files
D2037 cannot create temporary il file; clean temp directory of old il files
D2038 invalid argument 'argument'
D2040 error creating or communicating with child process