我在Delphi中有一些代码,整个代码都带有Assert语句。我知道有一个编译器指令{$C-},但是要添加到的指令太多。有没有一种方法可以通过编译器命令行或dpr文件中的某处完成它?

最佳答案

您也可以在命令行中使用$C-,或者在IDE的“项目->选项->编译器”中进行配置(在.dproj文件中进行配置)。

通过从命令行键入dcc32,可以获得命令行开关和选项的列表。可以使用命令重定向(如在dcc32 > dccCommands.txt中)将其重定向到文本文件,该文件将使用XE5的dcc32版本生成以下输出:

Embarcadero Delphi for Win32 compiler version 26.0
Copyright (c) 1983,2013 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)
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)

09-25 20:25