博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
有什么工具能提供预编译后的源代码啊?http://expert.csdn.net/Handler.ashx?id=1943733
阅读量:2400 次
发布时间:2019-05-10

本文共 8792 字,大约阅读时间需要 29 分钟。

我的意思是:我有一个很大的程序,九百多个文件,里面无数的预编译开关。我想找一个工具,只要我设定好我的基本开关后,就不再看到无关的代码行了;  

   
  郁闷中,让这东西搞得头都大了:(  
   
  只要有用,分不够只管说:) 问题点数:50、回复次数:34

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    
   
 

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

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

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

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

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

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

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

peanutz()   东西在哪?  

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

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

没必要吧,还不如用sourceInsight,sourceNavigator等源码工具。  

  看起来很方便

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文本,然后查看  
 

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

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

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

楼主的意思是想要一个编辑器,编辑器能根据   宏的定义   不同,显示和隐藏代码。  

  比如  
  #if   0  
  ...     //   这部分代码在编辑器重不显示。  
  #endif    
   
  这个功能没见过有哪个编辑器达到。因为这和编译器的参数有关系,不是静态可以支持的。  
  不过   有些编辑器支持   代码的折叠,比如   vs.net,   anjuta,这个勉强代替。

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

flyfreely(林雨亭)   说的就是我的意思:)  

   
  大家帮帮忙啊,兄弟我痛苦着呢,这个程序每个人加的开关都不同,文档又一点没有:(  
   
  我不可能每个开关都查一次全文啊:(

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

up

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

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

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

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

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

所有的C或者C++编译器都有开关用来输出.i文件(就是预处理过的源文件)的  

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

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

我不知道楼主具体用的是哪个编译器,但大部分的编译器都是上面提到的两种情况:  

  加编译参数或者是cpp和编译器本身就是独立的  
   
  另外,楼主有没有考虑过用VC做预处理之后,再拿到那个什么什么编译器上去编译?

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

我终于明白楼主的意思了,基本上所有的编译器都支持从命令行或者象VC那样从IDE给出  

  预定义的宏,你先把你要定义的宏设置好,然后再生成.i就好了

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

mark

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

兄弟们,这个贴子一定加分补给大家!:)  

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

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

to   :   DaNiao(鸿雁)    

  我用的是英文版的vc,没找到你说的地方

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

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

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

cpp啦

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

 

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

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

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

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

look

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

试过了,文件倒是生成了一个,不过打开只得到两行,什么也没有。空空的      

   
  :(  
   
  兄弟们加油啊:)  
  搞明白了再加二百分如何?:)

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

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

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

gcc   -E   输入文件   输出文件  

  上面的格式对不对?

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

gcc   -E   编译文件   >   输出文件  

   
  需要一个>就可以了,是重定向用的。

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

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

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

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

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

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

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

如果我是在一个文件夹下的很多文件里有东西,这应该编译哪一个?  

   
  用上面说的办法,文件倒是有了一个,九十多K,但打开就只有两行,为什么?

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

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

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

我倒:(  

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

转载地址:http://zvnob.baihongyu.com/

你可能感兴趣的文章
最美的七十个英语单词
查看>>
中国企业需要精益求精 (zt)
查看>>
第四章 计划工作概述
查看>>
物流基础知识(八)
查看>>
关于BPR和ERP的关系思考 (转载)
查看>>
写作必背200句
查看>>
职业经理人影响力自检手册(一)
查看>>
[HR规划]如何在中小企业进行人力资源规划(zt)
查看>>
ERP实施先要解决人的问题(zt)
查看>>
有效库存:供应链产业切肤之痛 (zt)
查看>>
李嘉诚给年青人提出的53条人生忠告(zt)
查看>>
第23课 企业信息资源规划系列讲堂之一
查看>>
第十七章 控制工作概述
查看>>
佳句与老友一起分享
查看>>
解读BPM风潮:缘何受到企业青睐?(转载)
查看>>
成功经理人与自我管理能力(转载)
查看>>
ERP系统应用与管理咨询(转载)
查看>>
精益思想—人、过程和技术的集成(zt)
查看>>
超市食品名称中英文对照(zt)
查看>>
第六章 预测与决策
查看>>