Delphi pre-Compilation

Source: Internet
Author: User

In Delphi, there are pre-compiled commands similar to C.
I. Instructions:
1. Define command:
Format: {$ define name}
Description: it is used to define a valid symbol (Symbol) in the current unit ). After definition, you can use the if def and ifndef commands to determine whether the symbol exists.
2. UNDEF command:
Format: {$ UNDEF name}
Description: Used to cancel a symbol defined in the current unit ). This command is used with define.
3. ifdef command:
Format: {$ ifdef name}
Note: If the name after the instruction has been defined, compile the instruction until between {$ else} or {$ endif} Code .
4. ifndef command:
Format: {$ ifndef name}
Note: If the name after the instruction is not defined, the code segment between {$ else} or {$ endif} after the instruction is compiled.
5. ifopt command:
Format: {$ ifopt switch}
Note: If the switch after the instruction has been set up, the code segment between {$ else} or {$ endif} after the instruction is compiled.
Example:

{$ Ifopt R +}
Writeln ('Enable range check during compilation ');
{$ Endif}
6. Else command:
Format: {$ else}
Note: Determine whether the code segment between the instruction and {$ endif} should be compiled or ignored by determining the conditional format of the prefix ifxxx.
7. endif command:
Format: {$ endif}
Description: Works with ifxxx to specify the condition pre-compilation section.Source codeThe end position of the CIDR block.

 

In addition, to define a globally valid name, you must use the menu settings:

Project-options-directories/conditionals, the following conditionals
This is the editing condition. What I want is a valid "Global" definition for {$ ifdef name} {$ else} {$ endif;

Note: It takes effect only after being built...

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.