Skip to content

Latest commit

 

History

History
75 lines (54 loc) · 3.09 KB

cl-environment-variables.md

File metadata and controls

75 lines (54 loc) · 3.09 KB
title ms.custom ms.date ms.reviewer ms.suite ms.technology ms.tgt_pltfrm ms.topic f1_keywords dev_langs helpviewer_keywords ms.assetid caps.latest.revision author ms.author manager
CL Environment Variables | Microsoft Docs
11/04/2016
cpp-tools
article
cl
C++
INCLUDE environment variable
cl.exe compiler, environment variables
LIBPATH environment variable
environment variables, CL compiler
2606585b-a681-42ee-986e-1c9a2da32108
9
corob-msft
corob
ghogen

CL Environment Variables

The CL tool uses the following environment variables:

  • CL and _CL_, if defined. The CL tool inserts the options and arguments defined in the CL environment variable at the beginning of the command line arguments, and adds the options and arguments defined in _CL_ to the end of the command line arguments, before processing.

  • INCLUDE, which must point to the \include subdirectory of your Visual C++ installation.

  • LIBPATH, which specifies directories to search for metadata files referenced by a #using directive. See #using for more information on LIBPATH.

You can set the CL or _CL_ environment variables using the following syntax:

SET CL=[ [option] ... [file] ...] [/link link-opt ...]  
SET _CL_=[ [option] ... [file] ...] [/link link-opt ...]  

For details on the arguments to the CL and _CL_ environment variables, see Compiler Command-Line Syntax.

You can use these environment variables to define the files and options you use most often and use the command line to define specific files and options for specific purposes. The CL and _CL_ environment variables are limited to 1024 characters (the command-line input limit).

You cannot use the /D option to define a symbol that uses an equal sign (=). You can substitute the number sign (#) for an equal sign. In this way, you can use the CL or _CL_ environment variables to define preprocessor constants with explicit values; for example, /DDEBUG#1 to define DEBUG=1.

For related information, see Set Environment Variables.

Examples

The following is an example of setting the CL environment variable:

SET CL=/Zp2 /Ox /I\INCLUDE\MYINCLS \LIB\BINMODE.OBJ  

When this environment variable is set, if you enter CL INPUT.C at the command line, this is the effective command:

CL /Zp2 /Ox /I\INCLUDE\MYINCLS \LIB\BINMODE.OBJ INPUT.C  

The following example causes a plain CL command to compile the source files FILE1.c and FILE2.c, and then link the object files FILE1.obj, FILE2.obj, and FILE3.obj:

SET CL=FILE1.C FILE2.C  
SET _CL_=FILE3.OBJ  
CL  

This has the same effect as the following command line:

CL FILE1.C FILE2.C FILE3.OBJ  

See Also

Setting Compiler Options
Compiler Options