Delphi与C语言类型转换对照
When converting C function prototypes to Pascal equivalent declarations, it's important to substitute the C function and argument types with the correct Pascal types. I often use a Type Translation Table for this, like the following in table 1 (optional parts on the C-side are noted between square brackets):
| C/C++ Type | ObjectPascal Type |
| unsigned short [int] | Word |
| [signed] short [int] | SmallInt |
| unsigned [int] | Cardinal { 3.25 fix } |
| [signed] int | Integer |
| UINT | LongInt { or Cardinal } |
| WORD | Word |
| DWORD | LongInt { or Cardinal } |
| unsigned long | LongInt { or Cardinal } |
| unsigned long int | LongInt { or Cardinal } |
| [signed] long | LongInt |
| [signed] long int | LongInt |
| char | Char |
| signed char | ShortInt |
| unsigned char | Byte |
| char* | PChar |
| LPSTR or PSTR | PChar |
| LPWSTR or PWSTR | PWideChar { 3.12 fix } |
| void* | Pointer |
| BOOL | Bool |
| float | Single |
| double | Double |
| long double | Extended |
| LP,NP,PP,P prefix: if first = T then T becomes P else P prefix | |
| HANDLE | THandle |
| FARPROC | TFarProc |
| ATOM | TAtom |
| TPOINT | TPoint |
| TRECT | TRect |
| COLORREF | TColorRef |
| OFSTRUCT | TOFStruct |
| DEBUGHOOKINFO | TDebugHookInfo |
| BITMAP | TBitMap |
| RGBTRIPLE | TRGBTriple |
| RGBQUAD | TRGBQuad |
| BITMAPCOREHEADER | TBitmapCoreHeader |
| BITMAPINFOHEADER | TBitmapInfoHeader |
| BITMAPINFO | TBitmapInfo |
| BITMAPCOREINFO | TBitmapCoreInfo |
| BITMAPFILEHEADER | TBitmapFileHeader |
| HANDLETABLE | THandleTable |
| METARECORD | TMetaRecord |
| METAHEADER | TMetaHeader |
| METAFILEPICT | TMetaFilePict |
| TEXTMETRIC | TTextMetric |
| NEWTEXTMETRIC | TNewTextMetric |
| LOGBRUSH | TLogBrush |
| LOGPEN | TLogPen |
| PATTERN | TPattern { TLogBrush } |
| PALETTEENTRY | TPaletteEntry |
| LOGPALETTE | TLogPalette |
| LOGFONT | TLogFont |
| ENUMLOGFONT | TEnumLogFont |
| PANOSE | TPanose |
| KERNINGPAIR | TKerningPair |
| OUTLINETEXTMETRIC | TOutlineTextMetric |
| FIXED | TFixed |
| MAT2 | TMat2 |
| GLYPHMETRICS | TGlyphMetrics |
| POINTFX | TPointFX |
| TTPOLYCURVE | TTTPolyCurve |
| TTPOLYGONHEADER | TPolygonHeader |
| ABC | TABC |
| RASTERIZER_STATUS | TRasterizer_Status |
| MOUSEHOOKSTRUCT | TMouseHookStruct |
| CBTACTIVATESTRUCT | TCBTActivateStruct |
| HARDWAREHOOKSTRUCT | THardwareHookStruct |
| EVENTMSG | TEventMsg |
| WNDCLASS | TWndClass |
| MSG | TMsg |
| MINMAXINFO | TMinMaxInfo |
| SEGINFO | TSegInfo |
| ACCEL | TAccel |
| PAINTSTRUCT | TPaintStruct |
| CREATESTRUCT | TCreateStruct |
| CBT_CREATEWND | TCBT_CreateWnd |
| MEASUREITEMSTRUCT | TMeasureItemStruct |
| DRAWITEMSTRUCT | TDrawItemStruct |
| DELETEITEMSTRUCT | TDeleteItemStruct |
| COMPAREITEMSTRUCT | TCompareItemStruct |
| WINDOWPOS | TWindowPos |
| WINDOWPLACEMENT | TWindowPlacement |
| NCCALCSIZE_PARAMS | TNCCalcSize_Params |
| SIZE | TSize |
| MENUITEMTEMPLATEHEADER | TMenuItemTemplateHeader |
| MENUITEMTEMPLATE | TMenuItemTemplate |
| DCB | TDCB |
| COMSTAT | TComStat |
| MDICREATESTRUCT | TMDICreateStruct |
| CLIENTCREATESTRUCT | TClientCreateStruct |
| MULTIKEYHELP | TMultiKeyHelp |
| HELPWININFO | THelpWinInfo |
| CTLSTYLE | TCtlStyle |
| CTLtype | TCtltype |
| CTLINFO | TCtlInfo |
| DDEADVISE | TDDEAdvise |
| DDEDATA | TDDEData |
| DDEPOKE | TDDEPoke |
| DDEAACK | TDDEAck |
| DEVMODE | TDevMode |
| KANJISTRUCT | TKanjiStruct |
It's also nice to have access to the translation of the special WINDOWS.H types, which is already done by Borland, and can be found in WINTYPES.PAS (it's a rewarding experience to compare these two files with each other - you'll learn a lot about C and Pascal conversion issues).
Now that we've handled the standard built-in (and Windows) types, let's look at the C type definition of WING_DITHER_TYPE that is present in the WING.H file.
typedef enum WING_DITHER_TYPE
{
WING_DISPERSED_4x4,
WING_DISPERSED_8x8,
WING_CLUSTERED_4x4
} WING_DITHER_TYPE;
This is a so -called enumerated type, and can be translated into an ObjectPascal enumerated type very easily:
type
WING_DITHER_TYPE =
(WING_DISPERSED_4x4,
WING_DISPERSED_8x8,
WING_CLUSTERED_4x4);
While most C DLL header files contain only constant definitions (of the form #define XYZ value) and function prototypes, type definitions are also found, and are therefore important to be able to convert.
Delphi与C语言类型转换对照的更多相关文章
- Delphi VS C语言类型转换对照
Delphi VS C语言类型转换对照 When converting C function prototypes to Pascal equivalent declarations, it's ...
- php 、asp、 java、 c#、 delphi之间的语言对照
PHP是一种跨平台的server端的嵌入式脚本语言.它大量地借用C,Java和Perl语言的语法, 并耦合PHP自己的特性,使WEB开发人员能够高速地写出动态产生页面. 它支持眼下绝大多数数据库. 另 ...
- Go 语言类型转换
类型转换用于将一种数据类型的变量转换为另外一种类型的变量.Go 语言类型转换基本格式如下: type_name(expression) type_name 为类型,expression 为表达式. 实 ...
- Go语言类型转换
类型转换用于将一种数据类型的变量转换为另外一种类型的变量. Go语言类型转换基本格式如下:表达式 T(v) 将值 v 转换为类型 T . Go语言各种类型转换及函数的高级用法:strconv包实现了基 ...
- GO语言学习(十七)Go 语言类型转换
Go 语言类型转换 类型转换用于将一种数据类型的变量转换为另外一种类型的变量.Go 语言类型转换基本格式如下: type_name(expression) type_name 为类型,expressi ...
- C语言类型转换原理
C语言类型转换 int a; a=1.23 这里把1.23赋值给a发生了隐式转换,原理如下: int a; float b=3.14; a=b; b赋值给a的过程:首先找一个中间变量是a的类型(该例中 ...
- C语言---类型转换
itoa 功 能:把一整数转换为字符串 用 法:char *itoa(int value, char *string, int radix); 详细解释:itoa是英文integer to array ...
- c语言类型转换注意事项
转载自: http://blog.csdn.net/zhuimengzh/article/details/6728492 1.隐式转换 C在以下四种情况下会进行隐式转换: 1.算 ...
- 执行效率做比较,Go、python、java、c#、delphi、易语言等
比较环境,在win7 64位,比较各种语言的整数型运算,下面的比较只作为单项比较.具体方式,40000*40000遍历相加.为了防止编译器优化,生成一个随机数. 1:c#,在NET2.0框架下作为 ...
随机推荐
- Enum扩展及MVC中DropDownListFor扩展方法的使用
public enum SearchState { /// <summary> /// 全部 /// </summary> [Description("全部" ...
- 50个提高PHP编程效率的方法
用单引号代替双引号来包含字符串,这样做会更快一些.因为PHP会在双引号包围的字符串中搜寻变量,单引号则不会,注意:只有echo能这么做,它是一种可以把多个字符串当作参数的“函数”(译注:PHP手册 ...
- android学习——Android Studio下创建menu布局文件
一.问题: android studio项目中没有看到menu文件夹: 在android studio项目中想要添加menu布局文件,一开始我的做法是:直接在res文件夹右键选择xml文件来添加,如下 ...
- 关于obj和基本类通过函数参数传进去执行是否改变原来的值
var obj = { p1 : 1, p2 : 2 }; (function(_/* 这个东东是地址的应用哦 */){ _.p1 = 3, _.p2 = 4 })(obj) var i = 2; ( ...
- Canvas识别相似图片
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- 【UVA 1583】Digit Generator
题 题意 a加上 a的各位数=b,则b是a的digitSum,a是b的generator,现在给你digitSum,让你求它的最小的generator. 分析 一种方法是: 预处理打表,也就是把1到1 ...
- ssh整合常见的错误
1.报错信息:java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refres ...
- Java编程思想学习(四) 访问权限
几种访问权限修饰词 public,protected,private,friendly(Java中并无该修饰词,即包访问权限,不提供任何访问修饰词) 使用时,放置在类中成员(域或方法)的定义之前的,仅 ...
- 【poj2546】 Circular Area
http://poj.org/problem?id=2546 (题目链接) 题意 求两圆的面积交 Solution 一道水题Wa死我了,肯定是昨晚搞太晚的缘故= =. 两圆的位置关系有5种,而这里要求 ...
- Sqlserver 读取EXCEL
1.1 启用本地读取设置 --启用EXEC sp_configure 'show advanced options', 1RECONFIGUREEXEC sp_configure 'Ad Hoc Di ...