设为首页 加入收藏

TOP

学习windows编程(3)―hello.c的疑惑(一)
2014-11-23 22:13:21 来源: 作者: 【 】 浏览:3
Tags:学习 windows 编程 hello.c 疑惑


上一篇,我们问了几个问题,这一篇就从hello.c的各个方面来研究研究,等到这一篇的结束来看这些疑惑有哪些是可以解答了的,当然还有一些可能要放到后面解决了……。

既然要抽丝剥茧,就要从手头已有的线索出发,同时加上搜索到的知识,以及自己的思考,任何问题的解决都是通过这个路径(当然,老板除外,老板这种生物只需要发出指令,然后得到结果就OK了……)。

我们现在有的,是一个hello.c文件,通过cl命令就可以生成目标hello.exe文件。

那我们就可以研究一下cl这个东西。

CL解释

CL.EXE(或cl.exe,似乎windows的文件系统对于大小写是不敏感的),是何许人也呢?直接引用微软的说辞吧。

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).

Note that all compiler options are case sensitive.

To compile without linking, use /c.

因为VC6的版本说明没有找到,这里的说明文字是Visual studio 2003的CL.EXE说明,不过都是一样的。从上面的说明可以看到CL是用来控制微软C和C++编译器(compiler)和链接器(linker),一共做了两件事情。编译器会生成COFF文件格式的目标文件(.obj);链接器会生成可执行文件(.exe)或者动态链接库文件(DLLs)。

对比我们之前的做法,的确是执行cl命令之后,生成了一个hello.obj文件和一个hello.exe文件。

另外在最后,还说明了一下,使用/c选项,则可以不进行链接过程。

CL选项

那cl还有哪些选项呢?使用cl / 来看看。

1 d: est>cl / 2 Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 3 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. 4 5 C/C++ COMPILER OPTIONS 6 7 -OPTIMIZATION- 8 9 /O1 minimize space /Op[-] improve floating-pt consistency10 /O2 maximize speed /Os favor code space11 /Oa assume no aliasing /Ot favor code speed12 /Ob inline expansion (default n=0) /Ow assume cross-function aliasing13 /Od disable optimizations (default) /Ox maximum opts. (/Ogityb1 /Gs)14 /Og enable global optimization /Oy[-] enable frame pointer omission15 /Oi enable intrinsic functions16 17 -CODE GENERATION-18 19 /G3 optimize for 80386 /Gy separate functions for linker20 /G4 optimize for 80486 /Ge force stack checking for all funcs21 /G5 optimize for Pentium /Gs[num] disable stack checking calls22 /G6 optimize for Pentium Pro /Gh enable hook function call23 /GB optimize for blended model (default) /GR[-] enable C++ RTTI24 /Gd __cdecl calling convention /GX[-] enable C++ EH (same as /EHsc)25 /Gr __fastcall calling convention /Gi[-] enable incremental compilation26 /Gz __stdcall calling convention /Gm[-] enable minimal rebuild27 /GA optimize for Windows Application /EHs enable synchronous C++ EH28 /GD optimize for Windows DLL /EHa enable asynchronous C++ EH29 30 /Gf enable string pooling /EHc extern "C" defaults to nothrow31 /GF enable read-only string pooling /QIfdiv[-] enable Pentium FDIV fix32 /GZ enable runtime debug checks /QI0f[-] enable Pentium 0x0f fix33 34 -OUTPUT FILES-35 36 /Fa[file] name assembly listing file /Fo name object file37 /FA[sc] configure assembly listing /Fp name precompiled header file38 /Fd[file] name .PDB file /Fr[file] name source browser file39 /Fe name executable file /FR[file] name extended .SBR file40 /Fm[file] name map file41 42 -PREPROCESSOR-43 44 /C dont strip comments /FI name forced include file45 /D{=|#} define macro /U remove predefined macro46 /E preprocess to stdout /u remove all predefine

首页 上一页 1 2 下一页 尾页 1/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇学习windows编程(4)--从libc.lib.. 下一篇问题一百一十五:第几天

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: