有什么工具能提供预编译后的源代码啊?http://expert.csdn.net/Handler.ashx?id=1943733

我的意思是:我有一个很大的程序,九百多个文件,里面无数的预编译开关。我想找一个工具,只要我设定好我的基本开关后,就不再看到无关的代码行了;  
   
  郁闷中,让这东西搞得头都大了:(  
   
  只要有用,分不够只管说:) 问题点数:50、回复次数:34Top

1 楼stukov2002(卡拉是头猪)回复于 2003-06-22 14:30:58 得分 0

VC的编译器CL.EXE的/P选项就是产生与处理结果的,看看msdn~~  
     
  Compiler   Reference  
  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    
   
  Top

2 楼feibob(灵猫)回复于 2003-06-22 14:39:03 得分 0

老大,我落后,不能用VC啊,我得用在仿真器上,所以只能是dos界面的东东:(Top

3 楼hdqqq(小西瓜)回复于 2003-06-22 14:48:57 得分 1

如果是标准的c代码,vc的编译器应该也可以。Top

4 楼peanutz()回复于 2003-06-22 15:19:53 得分 4

gcc,编译时加   -E   开关就行,看得到头文件宏展开等之后的情况,而不真正进行编译Top

5 楼feibob(灵猫)回复于 2003-06-22 16:04:58 得分 0

peanutz()   东西在哪?  
  我现在用的是一个内嵌式的工具,它把编译定义放在一个文件里,等makefile文件来找:(Top

6 楼maojincxj(scottpeck)回复于 2003-06-22 16:42:44 得分 2

没必要吧,还不如用sourceInsight,sourceNavigator等源码工具。  
  看起来很方便Top

7 楼lbaby(春天来了...)回复于 2003-06-22 17:29:27 得分 5

如果你有turbo   c2.0的话,可以利用tc中的cpp.exe来实现  
  cpp会生成一个默认后缀为.i的文件:  
  比如:  
  我们有一个hl.c内容如下:  
  #include   <stdio.h>  
     
  #define   __open_hl__   0  
     
  #ifdef   __open_hl__  
      #define   HL   "hello   world"  
  #endif  
  int   main(void)  
      {  
        printf(HL);  
        return   __open_hl__;  
      }  
  在命令行里我们这样调用cpp:  
  cpp   hl.c  
  然后,cpp就生成了一个后缀为i的hl.i文件,内容如下:  
  hl.c   1:    
  hl.c   2:    
  hl.c   3:    
  hl.c   4:    
  hl.c   5:    
  hl.c   6:    
  hl.c   7:    
  hl.c   8:   int   main(void)  
  hl.c   9:   {  
  hl.c   10:   printf("hello   world"   );  
  hl.c   11:   return   0   ;  
  hl.c   12:   }  
  hl.c   13:    
  我们可以看到,宏已经被替换完毕  
   
  这是cpp.exe   的最基本的用法,如果要看更多的说明  
  可以用  
  cpp   >   hlp.txt    
  来生成hlp.txt文本,然后查看  
  Top

8 楼peanutz()回复于 2003-06-22 17:52:31 得分 0

不太明白楼主的意思啊。。。:pTop

9 楼flyfreely(林雨亭)回复于 2003-06-22 19:06:45 得分 0

楼主的意思是想要一个编辑器,编辑器能根据   宏的定义   不同,显示和隐藏代码。  
  比如  
  #if   0  
  ...     //   这部分代码在编辑器重不显示。  
  #endif    
   
  这个功能没见过有哪个编辑器达到。因为这和编译器的参数有关系,不是静态可以支持的。  
  不过   有些编辑器支持   代码的折叠,比如   vs.net,   anjuta,这个勉强代替。Top

10 楼feibob(灵猫)回复于 2003-06-23 11:25:59 得分 0

flyfreely(林雨亭)   说的就是我的意思:)  
   
  大家帮帮忙啊,兄弟我痛苦着呢,这个程序每个人加的开关都不同,文档又一点没有:(  
   
  我不可能每个开关都查一次全文啊:(Top

11 楼maxcai(cailin)回复于 2003-06-23 12:00:01 得分 0

upTop

12 楼peanutz()回复于 2003-06-23 13:21:54 得分 0

“内嵌式的工具,它把编译定义放在一个文件里”???Top

13 楼williamx(WILL)回复于 2003-06-23 13:51:15 得分 2

vc的话,属性里有预编译,生成文件为   XX.iTop

14 楼DaNiao(鸿雁)回复于 2003-06-23 14:10:24 得分 5

所有的C或者C++编译器都有开关用来输出.i文件(就是预处理过的源文件)的  
  在VC里找到项目->设置->C++(编译器设置)->输出   然后选输出.i就可以了  
  gcc和cpp本来就是分开的,你直接用cpp做预处理就好了Top

15 楼DaNiao(鸿雁)回复于 2003-06-23 14:13:08 得分 2

我不知道楼主具体用的是哪个编译器,但大部分的编译器都是上面提到的两种情况:  
  加编译参数或者是cpp和编译器本身就是独立的  
   
  另外,楼主有没有考虑过用VC做预处理之后,再拿到那个什么什么编译器上去编译?Top

16 楼DaNiao(鸿雁)回复于 2003-06-23 14:15:52 得分 4

我终于明白楼主的意思了,基本上所有的编译器都支持从命令行或者象VC那样从IDE给出  
  预定义的宏,你先把你要定义的宏设置好,然后再生成.i就好了Top

17 楼bigtea(企鹅)回复于 2003-06-23 14:42:18 得分 0

markTop

18 楼feibob(灵猫)回复于 2003-06-23 18:12:52 得分 0

兄弟们,这个贴子一定加分补给大家!:)  
   
  继续继续,我现在用了一下,找了个CPP,但没有生成.i文件,倒是飞快地跑了一遍啊,这破文件放到哪了?  
   
  我们做的东西是跟硬件关系很大的,我也是才上手做这行,为了省钱,用的好象是个LUNIX下的编译器改到了DOS里进行仿真的,我也还没有搞明白呢。  
   
  大家帮帮忙啦:)  
   
  Top

19 楼oyd() oyd() oyd() oyd() oyd()回复于 2003-06-23 20:21:38 得分 0

to   :   DaNiao(鸿雁)    
  我用的是英文版的vc,没找到你说的地方Top

20 楼feibob(灵猫)回复于 2003-06-24 20:31:21 得分 0

大家说话啊,我每天都看着呢,一定结贴的:)Top

21 楼icecools(浮生若梦)回复于 2003-06-24 20:34:00 得分 1

cpp啦Top

22 楼stukov2002(卡拉是头猪)回复于 2003-06-24 20:45:09 得分 5

 
   
  命令行下使用TC的CPP工具:  
  cpp   -oOutput.txt   hello.c  
  结果输出到Output.txt文件了~  
   
  Top

23 楼peanutz()回复于 2003-06-25 13:16:59 得分 5

你的意思是你用的是CYGWIN?GNU工具系列在WIN32下的一个移植,这不就更方便了嘛,你用类似gcc   -E   myfile.c   >>   myoutputfile   试试Top

24 楼callzjy((草魚))回复于 2003-06-25 14:40:01 得分 0

lookTop

25 楼feibob(灵猫)回复于 2003-06-25 18:25:19 得分 0

试过了,文件倒是生成了一个,不过打开只得到两行,什么也没有。空空的      
   
  :(  
   
  兄弟们加油啊:)  
  搞明白了再加二百分如何?:)Top

26 楼peanutz()回复于 2003-06-26 13:08:52 得分 0

只有两行?你怎么用的?把你敲的命令贴上来看看Top

27 楼feibob(灵猫)回复于 2003-06-27 12:46:52 得分 0

gcc   -E   输入文件   输出文件  
  上面的格式对不对?Top

28 楼arfi()回复于 2003-06-27 13:29:06 得分 0

gcc   -E   编译文件   >   输出文件  
   
  需要一个>就可以了,是重定向用的。Top

29 楼peanutz()回复于 2003-06-27 13:35:40 得分 4

应该是“gcc   -E   输入文件   >>   输出文件”,>>是重定向呀!Top

30 楼peanutz()回复于 2003-06-27 13:37:10 得分 0

哦忘了,>也可以,一个是追加,一个是重新些,不过对你没多大影响的Top

31 楼peanutz()回复于 2003-06-27 13:39:53 得分 0

我得回复是对feibob(灵猫)的哈,不是说arfi()   说得不对:p,发贴那阵刚好没看到arfi()   的恢复Top

32 楼feibob(灵猫)回复于 2003-06-28 15:42:30 得分 0

如果我是在一个文件夹下的很多文件里有东西,这应该编译哪一个?  
   
  用上面说的办法,文件倒是有了一个,九十多K,但打开就只有两行,为什么?Top

33 楼peanutz()回复于 2003-06-28 15:54:45 得分 10

拜托,你是不是没拉垂直滚动条啊,展开之后有很多空白行的。。。Top

34 楼feibob(灵猫)回复于 2003-06-29 10:31:53 得分 0

我倒:(  
   
  前面这位兄弟真聪明啊,连我没有拉滚动条都知道:)  
   
  狂喜中。结,贴!  
   
  各位兄弟,我会另开两个贴子给分,大家进来拿分啊:) 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值