Delphi compiler instructions

Source: Internet
Author: User
Delphi's quick and high compiler mainly comes from the rigor of Object Pascal. Delphi is used to communicate with the compiler at any time. In most cases, it does not need to interfere with the compiler, but sometimes the compiler needs to be set as necessary.

**************************************** **************************************** **************

A.1 use the compilation Settings dialog box

The compile instruction of the compiler is used to specify the action and action of the compiler on the project compilation process. You can set it on the [project]-> [Options]-> [complier] Option page. Most compilation environments can be adjusted through this dialog box, it includes settings for code, syntax, debugging information, and so on.

1. Code Generation)

Optimization: code optimization Switch

Aligned record fields: Word aligned data. This compilation command can switch between the byte alignment and word alignment of the variable and the typed constant. Its function is global.

Stack frames: Windows stack frame. Its scope is local, which makes the compiler A Remote Process and function to generate a specific starting and ending code. This command is used in the real mode of Windows 3.0. It should be disabled for all Delphi applications.

Pentium-safe fdiv: Pentium Security fdiv check. This command can specify in the Pentium processor whether the compiler creates code that can detect and use defective floating-point Division commands.

2. runtime error (runtime errors)

Range checking: range check. The scope of this command is local and used to control the generation of the Code.

I/O checking: I/O check. This command is partial and is used to generate code for checking the Input and Output Processes and call results of a file. Generally, the function should be enabled.

Overflos checking: overflow check. The function is to generate code for the Arithmetic overflow check.

3. Syntax optings)

Strict var-strings: static variable string switch. Used to control the type check of strings transmitted as variable parameters.

Comlete Boolean Eval: determine the full Boolean expression. Used to determine the complete expression used to execute the force. It is determined by a full Boolean value, which may cause system crash, so it is generally not used.

Extended Syntax: the extension syntax switch. He can allow or disable Delphi's extended syntax.

Typed @ OPERATOR: checks the typed @ operator. Applies to local variable references to control the pointer value type returned by the @ operator.

Open parameters: Open the parameter switch. Used to control variable parameters declared using the string keyword. Open parameters allow passing variable strings of different sizes to the same process or function, which is generally used in assembly.

Huge strings: string type switch. Used to control ansistring and semi string switching. When it is turned on, it conforms to ansistring and when it is turned off, it complies with objective string.

Assignable typed constants: allocable type constant. It is used for backward compatibility with Delphi 1.0.

4. debug (debugging)

Debug information: debug information switch. Used to set whether to write debugging information to the compiled unit file (. DCU ).

Local symbols: local symbol switch. Allows or disables the creation of local symbol information.

Reference Info/definitions only: Symbol Information switch. Allows or disables the generation of symbolic reference information used by delohi's Object Browser.

Assertions: used to control attributes of local code.

Use DEBUG dcus: Use or disable vcl dcu file debugging.

5. Information (messages)

Show hints: Display suggestion.

Show Warnings: displays a warning.

**************************************** **************************************** **************

A.2 use the compilation command

In addition to setting the compiler by using the compilation Settings dialog box, you can also set the compiler by using the compilation instructions.
For local compiler settings, only compilation instructions are used.

For the switch compilation command, add the plus sign and minus sign indicating the switch status after the command is compiled to control the compiler. For example:

{$ B ++}: enables the full Boolean check.
{$ Q-}: Disable the overflow check.

Generally, the scope of the compiled instruction is the code part after the compiled instruction, and the full-process Compilation instruction should be prevented at the beginning of the Unit Interface part.
In the compilation Settings dialog box, the corresponding compilation commands are used to set the compiler in the code, as shown in the following table.

Set the Compilation instruction

Optimizations {$ O}

Aligned record fields {$}

Stack frames {$ w}

Pentium-safe fdiv {$ u}

Range checking {$ R}

I/O checking {$ I}

Overflow checking {$ Q}

Strict var-strings {$ v}

Comlete Boolean eval {$ B}

Extended syntax {$ x}

Typed @ operator {$ t}

Open parameters {$ p}

Huge strings {$ h}

Assertions typed constants {$ J}

Debug information {$ d}

Local sysnbols {$ l}

In addition to these compilation commands, there are some very useful compilation commands.
$ R filename: This compilation command is the most common compilation command. It is a resource file compilation command used to specify the resource files connected to the execution file and library, for example, in the project file (. DPR) contains {$ R *. res} compilation command, indicating that the suffix is. the resource file with the same name as the project file of Res can be connected to the execution file, or a resource file can be specified. The use of resource files is very important for writing Windows programs.

$ I filename: This Compilation instruction is similar to the # include function in C language and is used to specify the files included during compilation.

**************************************** **************************************** **************

A.3 use Conditional compilation commands

Conditional compilation commands are very important compilation commands, which control the generation of different code under different conditions (for example, different operating systems. Conditional compilation commands are included in
The following table describes the values in brackets.

Meaning of Conditional compilation commands

$ Define is used to define a condition symbol. Once defined, the condition symbol is true.

$ Else is used with $ ifdef. If the $ ifdef condition is false, compile only the last part of the source file $ Else.

$ Endif ends a condition segment starting with $ if.
 
$ Ifdef checks the condition symbol. If it is true, the source file is compiled.

$ Ifndef determines the condition symbol. If it is false, the source file is compiled.

$ Ifopt: Based on the Compilation Switch Status, compile the source file
 
$ UNDEF undo the previous condition symbol Definition

These Conditional compilation commands are very useful. For example, you can control compilation through the switch status:

{Ifopt R +}
Showmessage ('compiled with range-Checking ');
{$ Endif}

You can also define conditional symbols to control compilation:

{$ Define s}
......
{$ Ifdef s}
Showmessage ('yes ');
{$ Else}
Showmessage ('no ');
{$ Endif}

The compilation result is 'yes', but 'no' is displayed if {$ define s} is omitted '.
Some key condition symbols have been predefined in Delphi, as shown in the following table.

Condition symbol meaning

Verxx compiler version. XX indicates the version. For example, the compiler version of Delphi 1.0 is 80, and the compiler version of Delphi 5.0 is 130.

Win32 running environment (Windows 95.98/NT/2000)

CPU 386: intel386 or above

Console console or not

In addition to the preceding commands, the most common commands of Delphi compiler have been described. For common programs, Delphi does not require programmers to add compiler instructions. Delphi has completed the process automatically, however, to obtain high-quality applications or programs with special requirements, you must be familiar with the compilation commands of Delphi. Delphi not only has the fastest compiler, but also has very powerful compiler functions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.