CL Command-Line Error D2004

Message Text

'/option' requires an argument

This error message is written to whatever file or device was given to CL as standard error. It is therefore not subject to simple redirection from the Command Prompt, e.g., for capture to a file.


The cited command-line option requires an argument but was interpreted as having been given none.

For CL version 13.00.9466, the following are the options that can be given on the CL command line but which cause error D2004 if given without an argument:

/AI, /B1, /B1_5, /B2, /Bl, /Bp1, /Bp2, /Bpl, /Bpx, /Bx, /D, /d1, /d1_5, /d2, /F, /FI, /FU, /H, /I, /MP, /nl, /o, /Tc, /To, /Tp, /U, /V, /vd, /W, /w1, /w2, /w3, /w4, /wd, /we, /wo and /Zm

Due to a coding oversight, a /U with no argument is cited as /D in the message text.

There exists some scope for subtlety in how an option can be given with no argument. Refer especially to the general syntax of CL options for details of the common parsing of command-line tokens as concerns options and arguments. The following paragraphs summarise, with examples, two cases that seem at least possible in real-world use.

Some options do not permit their argument to begin with a switch character (i.e., a hyphen or forward slash). If the command-line token that starts such an option continues with a switch character, then the continuation is ignored, the option is regarded as having no argument, and error D2004 occurs. For example, whether the command

cl test.cpp /F-1

is plausible in trying -1 as shorthand for “the largest possible” value is never decided: the attempt is rejected not as having an argument that is in any way invalid but as having no argument. (As to the plausibility, retry but with the /F and the -1 separated and enclosed in quotes.)

Some options can be given as the whole of one command-line token yet take their argument from the next. This helps with readability at the command line and eases the construction in makefiles, e.g., by sparing concern for whether pasting of macros introduces white space. However, the next command-line token must come from the same command-line source, including that each line of a command file counts separately. For example, the command

cl test.cpp @test.txt 

is fine when the command file contains the one line

/I ..\inc

with or without white space after the /I, but terminates with error D2004 if the command file is the slightly different


since an option on one line of a command file cannot carry to the next.

Documentation Status

The product documentation seems not to mention error D2004, perhaps thinking that the error’s explanation is self-evident from the message text.