DELPHI Compile Details (1-10) (transfer)

xiaoxiao2021-03-06  42

Copyright CODESky.net

DELPHI Compilation Details (1) - Total

There are three types of Delphi compilation instructions, switch compilation instructions, parameter compile instructions, and conditional compilation instructions.

A compilation instruction is actually a flag (the compiler can identify the flag), and has its fixed syntax. The compiler compiles the program according to different instructions. You can place a compilation instruction in any location of the program. The start character of the compilation instruction is "$", which always appears after the "{" symbol, the actual part of the compilation instruction after $, can be one or more characters (depending on the directive), after the instruction Can contain one or more required parameters. The end of the compilation instruction is "}".

The following describes three compile instructions, respectively.

The switching compilation instruction is characterized by it has ON, OFF two conversion states. For single-character versions, you can add " " or "-" after compiling instructions. For long character versions, you can add "ON" or "OFF" after compiling instructions.

The switch compilation instruction is divided into both global and partial.

The global compilation instruction affects all compilation content, which must be placed before the program and unit declaration.

The local compilation instruction only affects local compilation content, its impact is the next recent compilation instruction. It can be placed in any location of the program.

Switch compilation instructions can be combined into a simple compilation instruction group, with a comma in the middle, but there is no space. For example: {$ b , r-, s-}

Parameter Compile Instructions The contents of the impact can be specified by parameters, and the parameters can be the file name or memory size.

Conditional Compile Instruction Specifies how to compile specific area segments. That is, if a condition is satisfied, it is compiled in one way, otherwise it is compiled according to another way.

All compile instructions (except for switch compilation instructions) should have at least one space between the name and parameters. For example: {$ b }

{$ R- Turn Off Range checking} {$ I types.inc} {$ m 32768,4096} {$ define debug} {$ ifdef debug}

{$ ENDIF}

DELPHI Compilation Details (2) - Arranging Field Type (Align Fields)

Type switch // Switch compile syntax {$ A }, {$ A-}, {$ A1}, {$ A2}, {$ A4}, or {$ a8} {$ align on}, {$ align off} , {$ Align 2}, {$ align 4}, or {$ align 8} default {$ a8} {$ align 8} scope local // local instruction

Description:

Command $ A Controls the record type fields and class structure fields in Delphi.

In the command {$ A1} or {$ A-}, the field is disorderly, all records and class structures are kept together, disseminated.

In the instruction {$ A2}, the fields of the record type do not have a packed, the fields in the type structure, and arrange them in byte order.

Under the instruction {$ A4}, the record type field does not have a packed, the field in the type structure, and is arranged in double-byte sequence.

Under the instruction {{$ A8} or {$ A }, the record type field does not have the field in the Packed, the type structure, and is arranged in four bytes.

Under the command $ A, regardless of the variable type, the constant type is always arranged in optimal access. Under {$ A8}, it is arranged in the fastest way.

DELPHI Compilation Details (3) - Note and Contacts of Comments and Compilation Directions (Comments and Compiler Directives)

The contents of the comments will be ignored by the compiler unless they are clutter functions or compile instructions.

There are several common comment structures {including content in this braces as comment, this content can be multi-line, as long as it can be between two braces, the contents of the comments are generally special fonts and Color display (suitable for all annotation types), it is easy to distinguish} (* In this bracket and asterisk, the content is comment *) // The content after the double-reverse slope is comment, which can only For a row. .

The comment cannot be nested. If {{}} will not work, but (* {} *) is allowed.

There is also a note that it is very similar to the ordinary annotation, but it has a special point to start with "{$", "}", and this comment is called the compilation instruction. Such like {$ warnings off}

It will tell the compiler not to generate an error warning message.

It is not a comment, but an indicator that tells the compiler how to compile.

DELPHI Compilation Directive Detailed (4) - Application Type

TYPE parameter // Parameter command syntax {$ appty gUI} or {$ appype console} default {$ appty gUI} Scope global // Local Directive

Description

$ AppType Compile Instruction Decide whether a Win32 console program (displayed in a DOS mode) or graphical interface program (mostly the program is displayed).

Under the {$ appType GUI} compile instruction, the compiler generates a graphical interface program, which is an ordinary Delphi application.

Under the {$ app type console} compile instruction, the compiler generates a console application. When a console program starts, a console window appears, and the user can interact with the application. At this time, the standard input / output command is automatically combined with the console program.

The iSconsole Boolean variable is in the System unit, which can view the program to run under the console program or the graphical interface program.

$ AppType Compile Ins can only appear in the program. He cannot appear in the library file unit file and package.

DELPHI Compilation Details (5) - ASSERT DIRECTIVES

Type Switch // Switch Type Syntax {$ C } OR {$ C -} {$ Assertions Off} DEFAULT {$ C } {$ Assertions ON} Scope local // Local

Description

$ C instructions determine whether the declaration code can be generated in the Delphi resource file. {$ C } is the default instruction.

This statement is usually not used in the test version of the test in the runtime.

DELPHI Compile Details (6) - Debugging Information

TYPE SWITCH / / Switch Type Syntax {$ D } OR {$ D -} {$ DebugInfo ON} DEBUGINFO OFF} default {$ d } {$ debuginfo on} Scope global // Local Directive

Description:

The $ d instruction decides whether to produce debug information. This information is a list of members generated by each process and logs the number of line numbers in the target code address in the resource file.

For unit files, debug information is recorded in unit object code together with the unit file. Debugging information Adds the size of the unit file, when the compiler compilation unit file is increased. But it does not affect the size and speed of the executable program.

When a program or unit file is compiled in the {$ D } state, comprehensive debugging allows you to run and set breakpoints in this module.

$ D is usually used with $ L, they can decide whether to generate partial debug symbol information.

DELPHI Compile Details (7) - Library files and shared objects

Parameter Type Parameter // compiler directive Syntax $ LIBPREFIX 'string' $ LIBSUFFIX 'string' $ LIBVERSION 'string'Defaults $ LIBPREFIX' lib 'or $ SOPREFIX' bpl '$ LIBSUFFIX' '$ LIBVERSION' 'Scope Global // partial Instructions :

$ Libprefix instructions overwrites the default 'lib' or 'bpl' output file prefix. For example, you can specify {$ libprefix 'dcl'}

For a design time package, you can use the following instructions to go all prefixes. {$ Libprefix ''}

$ Libsuffix instruction Add a specified suffix (before extending) to the output file name. For example, using {$ libsuffix '-2.1.3'} Add to Something.PAS, will generate Something-2.1.3.dll files

$ Libversion instruction Add a two-layer extension (after the original extension) to the output file name. For example, use {$ libversion '-2.1.3'} will generate libsomething.dll.2.1.3 files in Something.Pas

DELPHI Compilation Details (8) - Defining Instructions

Type Conditional Compilation // Conditions Syntax {$ Define Name}

Design a Delphi condition symbol based on a given name. This symbol needs to be declared and verified in this module, or appearing in {$ undef name}. If this name has been defined, {$ define name} will be invalid.

DELPHI Compilation Details (9) - Description Directive

TYPE parameter // Parameters syntax {$ description 'text'} scope global // local

Description

The $ d instruction is inserted into the module file you specified, and it should be placed in front of the executable file, the DLL file, or the package. Generally, the name, version number, and copyright are specified, but you can also specify the content you need to specify. For example: {$ d 'my application version 12.5'}

Strings cannot exceed 256 bytes. This description is generally not seen for end users. Sign your executive file, will be intended to your end users by descriptive text, version, and copyright information.

Tip: This text description must be included in the reference.

DELPHI Compile Details (10) - ELSE Directive

Type Conditional CompiLation // Conditions Syntax {$ ELSE}

Description:

This command is located after {$ ifxxx}, {$ ENDIF} or {$ IFEND}, is a boundary between the compilation and ignore the source code.

转载请注明原文地址:https://www.9cbs.com/read-71026.html

New Post(0)