VC 编译参数介绍

VC 编译参数介绍,第1张

VC编译器的编译链接参数非常之多,对程序生成在细节上的控制也是非常强大的。要深入了解编译器参数是比较困难的,但作个初步认识还是不太难。

编译参数可以在Project Setting中查看(Project菜单再选择Setting),如下图:

这些参数究竟代表什么意思了?可以通过在CMD窗口下输入cl /help(注1)查看各个参数的含义。

          C/C++ COMPILER OPTIONS

                        -OPTIMIZATION-优化

/O1 minimize space               /Op[-] improve floating-pt consistency

/O2 maximize speed                /Os favor code space

/Oa assume no aliasing              /Ot favor code speed

/Ob<n> inline expansion (default n=0) /Ow assume cross-function aliasing

/Od disable optimizations (default)     /Ox maximum opts. (/Ogityb1 /Gs)

/Og enable global optimization        /Oy[-] enable frame pointer omission

/Oi enable intrinsic functions

 

                         -CODE GENERATION-代码生成

/G3 optimize for 80386                 /Gy separate functions for linker

/G4 optimize for 80486                 /Ge force stack checking for all funcs

/G5 optimize for Pentium               /Gs[num] disable stack checking calls

/G6 optimize for Pentium Pro            /Gh enable hook function call

/GB optimize for blended model (default)  /GR[-] enable C++ RTTI

/Gd __cdecl calling convention          /GX[-] enable C++ EH (same as /EHsc)

/Gr __fastcall calling convention         /Gi[-] enable incremental compilation

/Gz __stdcall calling convention         /Gm[-] enable minimal rebuild

/GA optimize for Windows Application   /EHs enable synchronous C++ EH

/GD optimize for Windows DLL         /EHa enable asynchronous C++ EH

/Gf enable string pooling               /EHc extern "C" defaults to nothrow

/GF enable read-only string pooling      /QIfdiv[-] enable Pentium FDIV fix

/GZ enable runtime debug checks        /QI0f[-] enable Pentium 0x0f fix

 

                         -OUTPUT FILES-输出文件

/Fa[file] name assembly listing file     /Fo<file> name object file

/FA[sc] configure assembly listing      /Fp<file> name precompiled header file

/Fd[file] name .PDB file              /Fr[file] name source browser file

/Fe<file> name executable file         /FR[file] name extended .SBR file

/Fm[file] name map file

 

                         -PREPROCESSOR-预处理器

/C don't strip comments               /FI<file> name forced include file

/D<name>{=|#}<text> define macro     /U<name> remove predefined macro

/E preprocess to stdout                /u remove all predefined macros

/EP preprocess to stdout, no #line       /I<dir> add to include search path

/P preprocess to file                  /X ignore "standard places"

 

                         -LANGUAGE-语言

/Zi enable debugging information        /Zl omit default library name in .OBJ

/ZI enable Edit and Continue debug info /Zg generate function prototypes

/Z7 enable old-style debug info         /Zs syntax check only

/Zd line number debugging info only     /vd{0|1} disable/enable vtordisp

/Zp[n] pack structs on n-byte boundary   /vm<x> type of pointers to members

/Za disable extensions (implies /Op)     /noBool disable "bool" keyword

/Ze enable extensions (default)

 

                         -MISCELLANEOUS-杂项

/?, /help print this help message        /V<string> set version string

/c compile only, no link               /w disable all warnings

/H<num> max external name length     /W<n> set warning level (default n=1)

/J default char type is unsigned         /WX treat warnings as errors

/nologo suppress copyright message     /Yc[file] create .PCH file

/Tc<source file> compile file as .c      /Yd put debug info in every .OBJ

/Tp<source file> compile file as .cpp    /Yu[file] use .PCH file

/TC compile all files as .c             /YX[file] automatic .PCH

/TP compile all files as .cpp           /Zm<n> max memory alloc (% of default)

 

                        -LINKING-链接

/MD link with MSVCRT.LIB       /MDd link with MSVCRTD.LIB debug lib

/ML link with LIBC.LIB           /MLd link with LIBCD.LIB debug lib

/MT link with LIBCMT.LIB        /MTd link with LIBCMTD.LIB debug lib

/LD Create .DLL                 /F<num> set stack size

/LDd Create .DLL debug libary      /link [linker options and libraries]

 

全英文看着慢,其实在MSDN上可以找到中文说明。运行MSDN后,点击“目录”再在右边选择——开发工具和语言-->Visual Studio文档-->Visual C++-->生成C/C++程序-->C/C++生成参考-->编译C/C++程序-->编译器选项。下图展示了MSDN对编译器选项的说明,当然登录MSDN的网站也可以得到相同的信息。

下一篇将详细解释VC编译器在Debug和Release设置下编译参数的区别。

 

注1.cl.exe 是一种控制 Microsoft C 和 C++ 编译器和链接器的工具。编译器产生通用对象文件格式 (COFF) 对象 (.obj) 文件。 链接器产生可执行文件 (.exe) 或动态链接库文件 (DLL)。更多内容可以访问MSDN的网站。

转载请标明出处,原文地址:http://www.cnblogs.com/morewindows/archive/2011/08/29/2158807.html

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/2307372.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-07-22
下一篇 2022-07-25

发表评论

登录后才能评论

评论列表(0条)

保存