CL Command Line Options Must Precede Source File Name

ID: Q92499


The information in this article applies to:


SUMMARY

The syntax of the Microsoft C/C++ compiler CL command is as follows:


   cl [option] file ... [option | file]... [lib] [/link link-opt] 
If an option specification is placed on the command line incorrectly, no error message may be generated or an incorrect error message may be generated. This usually occurs if an option is placed after the file name. In some cases, an incorrect object file or executable file may be generated.


MORE INFORMATION

Two examples are listed below. There are many combinations of commands that may produce other symptoms.

Example 1: Debugging Information

Option Switch (/Zi) Specified Incorrectly

If the command to compile a "hello world" program is given as follows:

   cl hello.c /Zi 
the program compiles without error. However, if the program is debugged with the CodeView debugger, no source code is available. However, CodeView does not give a CV0101 warning message to indicate that no CodeView information is available because the CL command processor passes the /CO (CodeView) option to the linker. The resulting executable file contains some CodeView information.

The correct command to build an application and include CodeView information is as follows:

   cl /Zi hello.c 
If an application is built without the /Zi switch, CodeView issues the following warning message when it loads the application:
CV0101 Warning: no CodeView information for 'hello.exe'

Example 2: Memory Model Specified Incorrectly

If a "hello world" program is built in large memory model as follows:

   cl hello.c /AL 
the compiler performs some work and then issues the following message:
Command line error D2002 : conflict in memory-model specification
The D2002 error occurs because the compiler compiles HELLO.C for the small memory model (the default) and then attempts to compile a second source module with the large memory model. A HELLO.OBJ file is generated and its code is in the small memory model. The linker is not called because D2002 is a fatal error.

Additional query words: kbinf 7.00 8.00 8.00c 1.00 1.50


Keywords          : kb16bitonly 
Version           : 
Platform          : 
Issue type        : 

Last Reviewed: July 29, 1999