欢迎光临
我们一直在努力

如何将c/c++程序转译成delphi(四)_delphi教程

建站超值云服务器,限时71元/月

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 compilation
  • 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 uses 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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何将c/c++程序转译成delphi(四)_delphi教程
分享到: 更多 (0)

相关推荐

  • 暂无文章