CL Command Line Options Must Precede Source File Name

Last reviewed: July 17, 1997
Article ID: Q92499
6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50
MS-DOS                 | OS/2       | WINDOWS
kbtool

The information in this article applies to:

  • The Microsoft C/C++ Compiler (CL.EXE), included with:

        - Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax
        - Microsoft C for OS/2, versions 6.0 and 6.0a
        - Microsoft C/C++ for MS-DOS, version 7.0
        - Microsoft Visual C++ for Windows, versions 1.0 and 1.5
    

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 reference words: kbinf 7.00 8.00 8.00c 1.00 1.50
KBCategory: kbtool
KBSubcategory: CLIss
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 17, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.