How to translate CC ++ programs into delphi (four)

zhaozj2021-02-17  45

2.3. #Defines as constants

C and C USE #defines in Several Ways. In a c header file #define can be used

For Declaring a constant for declaring a symbol for conditional compiration for macros

This Chapter Describes The Translation of #define Into delphi constants.

The Format for Declaring Constants IN C is:

#define nameofconstant value

For example:

#define time_zone_id_unknown 0

#define Time_ZONE_ID_STANDARD 1

#define time_zone_id_daylight 2

The Translation in Delphi IS:

Const

Time_ZONE_ID_UNKNOWN = 0;

Time_ZONE_ID_STANDARD = 1;

Time_ZONE_ID_DAYLIGHT = 2;

Back to Contents

2.3.1. Hexadecimal Values

C Usees the prefix 0x to specify a hexadecimal value. For example, the c declaration

#define my_constant 0xff

Translates to delphi as

Const

MY_CONSTANT = $ FF;

Back to Contents

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

New Post(0)