Microsoft KB Archive/92499

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

CL Command Line Options Must Precede Source File Name

Q92499



The information in this article applies to:


  • The 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++, versions 1.0, 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 query words: kbinf 7.00 8.00 8.00c 1.00 1.50

Keywords : kb16bitonly
Issue type :
Technology : kbVCsearch kbAudDeveloper kbCVCComp


Last Reviewed: May 8, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.