VC命令行编译参数介绍

来源:互联网 发布:权威的时尚杂志 知乎 编辑:程序博客网 时间:2024/05/16 14:26
VC命令行编译参数介绍


CL.exe是控制Microsoft C和C++编译器与链接器的32位工具。编译器产生通用对象文件格式(COFF)对象(.obj)文件。链接器产生可执行文件   (.exe)或动态链接库文件(DLL)。


 


CL   命令行使用下列语法:      


CL   [option...]   file...   [option   |   file]...   [lib...]   [@command-file]   [/link   link-opt...]   
下表说明CL   命令的输入项意义


    
option   一个或多个   CL   选项。请注意,所有选项都应用于所有指定的源文件。选项是由一个正斜杠   (/)   或一个短划线   (–)   指定的。如果某个选项带有参数,则该选项的说明指定在选项和参数之间是否允许有空格。选项名(/HELP   选项除外)区分大小写。有关更多信息,请参阅   CL   选项的顺序。  


    
file   一个或多个源文件、.obj   文件或库的名称。CL   编译源文件并将   .obj   文件和库的名称传递给链接器。有关更多信息,请参阅   CL   文件名语法。


lib   一个或多个库名。CL   将这些名称传递给链接器。     
    
command-file   包含多个选项和文件名的文件。有关更多信息,请参阅   CL   命令文件。     
    
link-opt   一个或多个链接器选项。CL   将这些选项传递给链接器。


您可以指定任意数目的选项、文件名和库名,条件是命令行上的字符数不超过   1024,该限制是操作系统指定的。  


 


 


 


编译器


 


注意,所有编译器选项都区分大小写。


若要编译但不链接,请使用   /c。


使用   NMAKE   生成输出文件。     
使用   BSCMAKE   支持类浏览。


以下是一个完整的编译器选项分类列表。


一、优化   
    
  选项             作用     
  /O1   创建小代码     
  /O2   创建快速代码     
  /Oa   假设没有别名     
  /Ob   控制内联展开     
  /Od   禁用优化     
  /Og   使用全局优化     
  /Oi   生成内部函数     
  /Op   改善浮点数一致性     
  /Os   代码大小优先     
  /Ot   代码速度优先     
  /Ow   假定在函数调用中使用别名     
  /Ox   使用最大优化   (/Ob1gity   /Gs)     
  /Oy   省略框架指针


二、代码生成   
    
  选项   作用     
  /clr   启用C++ 的托管扩展并产生在公共语言运行库上运行的输出文件     
  /EH   指定异常处理模型     
  /G3   优化代码以优选386处理器。在Visual C++ 5.0中已经停用,编译器将忽略此选项     
  /G4   优化代码以优选486处理器。在Visual C++ 5.0中已经停用,编译器将忽略此选项     
  /G5   优化代码以优选Pentium     
  /GB   与/G6等效;将 _M_IX86的值设置为600     
  /Gd   使用__cdecl 调用约定     
  /Ge   激活堆栈探测     
  /GF   
  /GF   启用字符串池     
  /GH   调用挂钩函数_penter     
  /GH   调用挂钩函数_pexit     
  /GL   启用全程序优化     
  /Gm   启用最小重新生成     
  /Gr   启用运行时类型信息(RTTI)     
  /Gr   使用 __fastcall 调用约定     
  /GS   控制堆栈探测     
  /GT   支持使用静态线程本地存储区分配的数据的纤程安全     
  /GX   启用同步异常处理     
  /Gy   启用函数级链接     
  /GZ   使用   __stdcall   调用约定     
  /MD   使用   MSVCRT.lib   创建多线程   DLL     
  /MDd   使用   MSVCRTD.lib   创建调试多线程   DLL     
  /ML   使用   LIBC.lib   创建单线程可执行文件     
  /MLd   使用   LIBCD.lib   创建调试单线程可执行文件     
  /MT   使用   LIBCMT.lib   创建多线程可执行文件     
  /MTd   使用   LIBCMTD.lib   创建调试多线程可执行文件


三、输出文件   
    
  选项   作用     
  /FA   创建列表文件
  /FA   设置列表文件名          


  /Fd   重命名程序数据库文件     
  /Fe   重命名可执行文件     
  /Fm   创建映射文件     
  /Fo   创建对象文件     
  /Fp   指定预编译头文件名     
  /FR   
  /FR   生成浏览器文件     
  /Fx   将插入的代码与源文件合并


四、调试   
    
  选项   作用     
  /GS   缓冲区安全检查     
  /GZ   与   /RTC1   相同     
  /RTC   启用运行时错误检查     
  /Wp64   检测   64   位可移植性问题     
  /Yd   将完整的调试信息放在所有对象文件中     
  /Yl   创建调试库时插入   PCH   引用     
  /Z7   生成与   C   7.0   兼容的调试信息     
  /Zd   生成行号     
  /Zi   生成完整的调试信息


五、预处理器   
    
  选项   作用     
  /AI   指定在解析传递到#using   指令的文件引用时搜索的目录     
  /c   在预处理期间保留注释     
  /D   定义常数和宏     
  /E   将预处理器输出复制到标准输出     
  /EP   将预处理器输出复制到标准输出     
  /Fl   预处理指定的包含文件     
  /FU   强制使用文件名,就像它已被传递到#using   指令一样     
  /I   在目录中搜索包含文件     
  /P   将预处理器输出写入文件     
  /U   移除预定义宏     
  /U   移除所有的预定义宏     
  /X   忽略标准包含目录     
  /ZI   将调试信息包含在与“编辑并继续”兼容的程序数据库中


六、语言   
    
  选项   作用     
  /noBool   取消   C++   bool、true   和   false   关键字     
  /vd   取消或启用隐藏的   vtordisp   类成员     
  /vmb   对指向成员的指针使用最佳的基     
  /vmg   对指向成员的指针使用完全一般性     
  /vmm   声明多重继承     
  /vms   声明单一继承     
  /vmv   声明虚拟继承     
  /Za   禁用语言扩展     
  /Zc   在   /Ze   下指定标准行为     
  /Ze   启用语言扩展     
  /Zg   生成函数原型     
  /Zl   从   .obj   文件中移除默认库名     
  /Zpn   封装结构成员     
  /Zs   只检查语法


七、链接   
    
  选项   作用     
  /F   设置堆栈大小     
  /LD   创建动态链接库     
  /LDd   创建调试动态链接库     
  /link   将指定的选项传递给   LINK     
  /MD   使用   MSVCRT.lib   编译以创建多线程   DLL     
  /MDd   使用   MSVCRTD.lib   编译以创建调试多线程   DLL     
  /ML   使用   LIBC.lib   编译以创建单线程可执行文件     
  /MLd   使用   LIBCD.lib   编译以创建调试单线程可执行文件     
  /MT   使用   LIBCMT.lib   编译以创建多线程可执行文件     
  /MTd   使用   LIBCMTD.lib   编译以创建调试多线程可执行文件


八、预编译头   
    
  选项   作用     
  /Y-   忽略当前生成中的所有其他预编译头编译器选项     
  /Yc   创建预编译头文件     
  /Yd   将完整的调试信息放在所有对象文件中     
  /Yu   在生成期间使用预编译头文件     
  /YX   自动处理预编译头


九、杂项   
    
  选项   作用     
  @   指定响应文件     
  /?   列出编译器选项     
  /c   编译但不链接     
  /H   限制外部(公共)名称的长度     
  /HELP   列出编译器选项     
  /J   更改默认的   char   类型     
  /NOLOGO   取消显示登录版权标志     
  /QI0f   确保   Pentium   0F   指令没有问题     
  /QIfdiv   FDIV、FPREM、FPTAN   和   FPATAN   指令有缺陷的   Intel   Pentium   微处理器的变通方法     
  /QIfist   当需要从浮点类型转换为整型时取消   Helper   函数   _ftol   的调用     


  /showIncludes   在编译期间显示所有包含文件的列表     
  /Tc   
  /Tc   指定   C   源文件     
  /Tp   
  /Tp   指定   C++   源文件     
  /V   设置版本字符串     
  /w   设置警告等级     
  /w   禁用所有警告     
  /Wall   启用所有警告,包括默认情况下禁用的警告     
  /WL   在从命令行编译   C++   源代码时启用错误信息和警告消息的单行诊断     
  /Zm   设置编译器的内存分配限制     


 


英文版


 


 CL.EXE   is   a   32-bit   tool   that   controls   the   Microsoft   C   and   C++   compilers   and   linker.   The   compilers   produce   Common   Object   File   Format   (COFF)   object   (.OBJ)   files.   The   linker   produces   executable   (.EXE)   files   or   dynamic-link   libraries   (DLLs).   
    
  For   information   on   specifying   options,   see   Set   Compiler   Options.   Other   topics   covered   in   this   section   are   Fast   Compilation   and   CL   Invokes   the   Linker.     
    
  To   compile   without   linking,   use   /c   on   the   command   line   or   click   the   Compile   command   on   the   Build   menu.     
    
  The   following   is   a   comprehensive,   alphabetic   list   of   options   for   the   compiler   (CL.EXE).   Click   any   option   name   for   specific   information   about   it.   Also   see   the   compiler   options   listed   by   category   of   purpose.     
    
  Option   name   and   arguments   Purpose     
  /C   Preserves   comments   during   preprocessing     
  /c   Compiles   without   linking     
  /Dname[=   |   #   [{string   |   number}]   ]   Defines   constants   and   macros     
  /E   Copies   preprocessor   output   to   standard   output     
  /EH{s|a}[c][-]   Specifies   the   model   of   exception   handling     
  /EP   Copies   preprocessor   output   to   standard   output     
  /F   number   Sets   stack   size     
  /FA[c|s]   Creates   a   listing   file     
  /Fa   Sets   listing   file   name     
  /Fdfilename   Renames   program   database   file     
  /FD   Generate   file   dependencies     
  /Fefilename   Renames   the   executable   file     
  /FIfilename   Preprocesses   the   specified   include   file     
  /Fm[filename]   Creates   a   map   file     
  /Fofilename   Creates   an   object   file     
  /Fpfilename   Specifies   a   precompiled   header   file   name     
  /FR[filename]   
  /Fr[filename]   Generate   browser   files     
  /G3   Optimizes   code   to   favor   the   386   processor.   Phased   out   in   Visual   C++   5.0,   the   compiler   will   ignore   this   option     
  /G4   Optimizes   code   to   favor   the   486   processor.   Phased   out   in   Visual   C++   5.0,   the   compiler   will   ignore   this   option     
  /G5   Optimizes   code   to   favor   the   Pentium   processor     
  /G6   Optimizes   code   to   favor   the   Pentium   Pro   processor     
  /GA   Optimizes   code   for   Windows   application     
  /GB   Optimizes   code   to   favor   the   Pentium   processor.   Blends   optimizations   for   the   80386   (/G3),   80486   (/G4),   Pentium   (/G5),   and   Pentium   Pro   (/G6)   options.     
  /GD   Optimizes   code   for   Windows   DLL     
  /Gd   Uses   the   __cdecl   calling   convention     
  /Ge   Activates   stack   probes       
  /GF   
  /Gf   Enable   string   pooling     
  /Gh   Calls   hook   function,   __penter     
  /Gi   Enables   incremental   compilation     
  /Gm   Enables   minimal   rebuild     
  /GR   Enables   run-time   type   information   (RTTI)     
  /Gr   Uses   the   __fastcall   calling   convention     
  /Gssize   Controls   stack   probes     
  /GT   Supports   fiber   safety   for   data   allocated   using   static   thread-local   storage.     
  /GX[–]   Enables   synchronous   exception   handling     
  /Gy   Enables   function-level   linking     
  /GZ   Catch   release-build   errors   in   debug   build     
  /Gz   Uses   the   __stdcall   calling   convention     
  /Hnumber   Restricts   the   length   of   external   (public)   names     
  /HELP   Lists   the   compiler   options     
  /Idirectory   Searches   a   directory   for   include   files     
  /J   Changes   the   default   char   type     
  /LD   Creates   a   dynamic-link   library     
  /LDd   Creates   a   debug   dynamic-link   library     
  /link   option   Passes   the   specified   option   to   LINK     
  /MD   Creates   a   multithreaded   DLL,   using   MSVCRT.LIB     
  /MDd   Creates   a   debug   multithreaded   DLL,   using   MSVCRTD.LIB     
  /ML   Creates   a   single-threaded   executable   file,   using   LIBC.LIB     
  /MLd   Creates   a   debug   single-threaded   executable   file,   using   LIBCD.LIB     
  /MT   Creates   a   multithreaded   executable   file,   using   LIBCMT.LIB     
  /MTd   Creates   a   debug   multithreaded   executable   file,   using   LIBCMTD.LIB     
  /nologo   Suppresses   display   of   sign-on   banner     
  /O1   Creates   small   code     
  /O2   Creates   fast   code     
  /Oa   Assumes   no   aliasing     
  /Ob   Controls   inline   expansion     
  /Od   Disables   optimization     
  /Og   Uses   global   optimizations     
  /Oi   Generates   intrinsic   functions     
  /Op   Improves   floating-point   consistency     
  /Os   Favors   small   code       
  /Ot   Favors   fast   code       
  /Ow   Assumes   aliasing   across   function   calls     
  /Ox   Uses   maximum   optimization   (/Ob1gity   /Gs)     
  /Oy   Omits   frame   pointer     
  /Qlf     Generates   additional   debugging   information   for   kernal-mode   device   drivers.     
  /QI0f   Performs   Pentium   0x0f   erratum   fix     
  /QIfdiv[–]   Performs   Pentium   FDIV   erratum   fix     
  /P   Writes   preprocessor   output   to   a   file     
  /Tcfilename   
  /TC   Specifies   a   C   source   file     
  /Tpfilename   
  /TP   Specifies   a   C++   source   file     
  /Usymbol   Removes   a   predefined   macro     
  /u   Removes   all   predefined   macros     
  /V   Sets   the   version   string     
  /vd{0|1}   Suppresses   or   enables   hidden   vtordisp   class   members     
  /vmb   Uses   best   base   for   pointers   to   members     
  /vmg   Uses   full   generality   for   pointers   to   members     
  /vmm   Declares   multiple   inheritance     
  /vms   Declares   single   inheritance     
  /vmv   Declares   virtual   inheritance     
  /Wlevel     Sets   warning   level     
  /w   Disables   all   warnings     
  /X   Ignores   the   standard   include   directory     
  /Yc[filename]   Creates   a   precompiled   header   file     
  /Yd   Places   complete   debugging   information   in   all   object   files     
  /Yu[filename]   Uses   a   precompiled   header   file   during   build     
  /YX   Automates   precompiled   header       
  /Z7   Generates   C   7.0–compatible   debugging   information     
  /Za   Disables   language   extensions     
  /Zd   Generates   line   numbers     
  /Ze   Enables   language   extensions     
  /Zg   Generates   function   prototypes     
  /Zi   Generates   complete   debugging   information     
  /ZI   Includes   debug   information   in   a   program   database   compatible   with   Edit   and   Continue.     
  /Zl   Removes   default   library   name   from   .OBJ   file     
  /Zmnumber   Sets   the   compiler's   memory   allocation   limit     
  /Zn   Turns   off   SBRPACK   for   .SBR   files     
  /Zpn   Packs   structure   members     
  /Zs   Checks   syntax   only
原创粉丝点击