DELPHI 编译开关

做任何事情,一定要沉下去,大部分时间坚持到最后的是胜利者

1. 先用一般的文书编辑器建好一个 MySet.inc 的普通文本文件 , 内容为 :

{$H+}{$DEFINE _Proversion}

2.在我们的程序中 , 加入一列 {$I MySet.inc}, 例如 :

unit Unit1;

{$I MySet.inc}

interface

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);

begin

{$IFDEF _ProVersion}

ShowMessage(' 专业版 ');

{$Else}

ShowMessage(' 只有专业版才有此功能 ');

{$ENDIF}

end;

这是子程序的观念嘛 ! 没错 , 就是这么简单而已 , 以后如果有任何变化 , 修改 MySet.INC, 然后 Project/Buile All 即可 , 实在

是够简单的了。基本动作会了之后 , 让我告诉你多一点有关 {$I 文件名称 } 的事。

3.一旦应用了 {$I 文件名称 },几乎等于 Compiler 在编译时,让 Compiler 将这个档案的内容贴进我们的程序中的那个位置。

   如果没有注明扩展名 , Delphi 预设这个档案是 .PAS 。

    如果在项目的目录中找不到这个档案的话 , Delphi 会陆续搜寻 Tools/Options/Library 中的 Library Path 中的目录。

另外 , 当您写作了一个 DLL, 使用者在使用其中的函数前必须宣告过 , 如果能够一并提供这些函数的宣告文件 , 使用者只要一行 {$I

xxx}即可 , 是不是很方便呢 ?


其实 {$J+} 时还有一个妙用 , 那就是宣告出类似 C 语言 static 的变量 , 换句话说 ,产生了一个与 Application 相同生命周期的变量。

在这种情形下 , 变量只在第一次使用时才会建立 , 函数或程序结束时 , 该变量也不会消灭 , 下一次再呼叫到这个函数或程序时 , 我

们仍然可以参考到上次执行结束时的值。让我们试一下这个例子 :

{$J+}

procedure TForm1.Button1Click(Sender: TObject);

const

i: integer = 0;

begin

ShowMessage(IntToStr(i));

Inc(i);

ShowMessage(IntToStr(i));

end;

第一次执行时, 我们分别会看到「0」「1」, 再点一次这个按钮时, 看到的将是「1」「2」。

如何获得delphi所有编译开关.

你自己在dos下
dcc32/? > 1.txt <enter>

 

Embarcadero Delphi for Win32 compiler version 33.0
Copyright (c) 1983,2018 Embarcadero Technologies, Inc.

Syntax: dcc32 [options] filename [options]

  -A<unit>=<alias> = Set unit alias
  -B = Build all units             
  -CC = Console target             
  -CG = GUI target                 
  -D<syms> = Define conditionals   
  -E<path> = EXE/DLL output directory
  -F<offset> = Find error          
  -GD = Detailed map file          
  -GP = Map file with publics      
  -GS = Map file with segments     
  -H = Output hint messages        
  -I<paths> = Include directories  
  -J = Generate .obj file          
  -JPHNE = Generate C++ .obj file, .hpp file, in namespace, export all
  -JL = Generate package .lib, .bpi, and all .hpp files for C++
  -K<addr> = Set image base addr   
  -LE<path> = package .bpl output directory
  -LN<path> = package .dcp output directory
  -LU<package> = Use package       
  -M = Make modified units         
  -NU<path> = unit .dcu output directory
  -NH<path> = unit .hpp output directory
  -NO<path> = unit .obj output directory
  -NB<path> = unit .bpi output directory
  -NX<path> = unit .xml output directory
  -NS<namespaces> = Namespace search path
  -O<paths> = Object directories   
  -P = look for 8.3 file names also
  -Q = Quiet compile               
  -R<paths> = Resource directories 
  -TX<ext> = Output name extension 
  -U<paths> = Unit directories     
  -V = Debug information in EXE    
  -VR = Generate remote debug (RSM)
  -VT = Debug information in TDS   
  -VN = TDS symbols in namespace   
  -W[+|-|^][warn_id] = Output warning messages
  -Z = Output 'never build' DCPs   
  -$<dir> = Compiler directive     
  --help = Show this help screen   
  --version = Show name and version
  --codepage:<cp> = specify source file encoding
  --default-namespace:<namespace> = set namespace
  --depends = output unit dependency information
  --doc = output XML documentation 
  --drc = output resource string .drc file
  --no-config = do not load default dcc32.cfg file
  --description:<string> = set executable description
  --inline:{on|off|auto} = function inlining control
  --legacy-ifend = allow legacy $IFEND directive
  --zero-based-strings[+|-] = strings are indexed starting at 0
  --peflags:<flags> = set extra PE Header flags field
  --peoptflags:<flags> = set extra PE Header optional flags field
  --peosversion:<major>.<minor> = set OS Version fields in PE Header (default: 5.0)
  --pesubsysversion:<major>.<minor> = set Subsystem Version fields in PE Header (default: 5.0)
  --peuserversion:<major>.<minor> = set User Version fields in PE Header (default: 0.0)
  --lib-version:<version> = Output package name version
  --lib-suffix:<suffix> = Output package name suffix
Compiler switches: -$<letter><state> (defaults are shown below)
  A8  Aligned record fields         
  B-  Full boolean Evaluation       
  C+  Evaluate assertions at runtime
  D+  Debug information             
  G+  Use imported data references  
  H+  Use long strings by default   
  I+  I/O checking                  
  J-  Writeable structured consts   
  L+  Local debug symbols           
  M-  Runtime type info             
  O+  Optimization                  
  P+  Open string params            
  Q-  Integer overflow checking     
  R-  Range checking                
  T-  Typed @ operator              
  U-  Pentium(tm)-safe divide       
  V+  Strict var-strings            
  W-  Generate stack frames         
  X+  Extended syntax               
  Y+  Symbol reference info         
  Z1  Minimum size of enum types    
Stack size: -$M<minStackSize[,maxStackSize]> (default 16384,1048576)
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

蝈蝈(GuoGuo)

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值