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语言类型转换对照的更多相关文章

  1. Delphi VS C语言类型转换对照

    Delphi VS C语言类型转换对照   When converting C function prototypes to Pascal equivalent declarations, it's ...

  2. php 、asp、 java、 c#、 delphi之间的语言对照

    PHP是一种跨平台的server端的嵌入式脚本语言.它大量地借用C,Java和Perl语言的语法, 并耦合PHP自己的特性,使WEB开发人员能够高速地写出动态产生页面. 它支持眼下绝大多数数据库. 另 ...

  3. Go 语言类型转换

    类型转换用于将一种数据类型的变量转换为另外一种类型的变量.Go 语言类型转换基本格式如下: type_name(expression) type_name 为类型,expression 为表达式. 实 ...

  4. Go语言类型转换

    类型转换用于将一种数据类型的变量转换为另外一种类型的变量. Go语言类型转换基本格式如下:表达式 T(v) 将值 v 转换为类型 T . Go语言各种类型转换及函数的高级用法:strconv包实现了基 ...

  5. GO语言学习(十七)Go 语言类型转换

    Go 语言类型转换 类型转换用于将一种数据类型的变量转换为另外一种类型的变量.Go 语言类型转换基本格式如下: type_name(expression) type_name 为类型,expressi ...

  6. C语言类型转换原理

    C语言类型转换 int a; a=1.23 这里把1.23赋值给a发生了隐式转换,原理如下: int a; float b=3.14; a=b; b赋值给a的过程:首先找一个中间变量是a的类型(该例中 ...

  7. C语言---类型转换

    itoa 功 能:把一整数转换为字符串 用 法:char *itoa(int value, char *string, int radix); 详细解释:itoa是英文integer to array ...

  8. c语言类型转换注意事项

    转载自: http://blog.csdn.net/zhuimengzh/article/details/6728492 1.隐式转换     C在以下四种情况下会进行隐式转换:        1.算 ...

  9. 执行效率做比较,Go、python、java、c#、delphi、易语言等

    比较环境,在win7   64位,比较各种语言的整数型运算,下面的比较只作为单项比较.具体方式,40000*40000遍历相加.为了防止编译器优化,生成一个随机数. 1:c#,在NET2.0框架下作为 ...

随机推荐

  1. Javascript基础系列之(三)数据类型 (数值 Number)

    javascript中想限定一个数的数值,无需限定它是整数还是浮点数型 var num1 = 80 ; var num2 = 55.51; var num3 = -34; var num4 = 9e5 ...

  2. 配置域主DNS服务器

    一.DNS服务器的类型 ①Primary DNS Server(Master) 一个域的主服务器保存着该域的zone配置文件,该域所有的配置.更改都是在该服务器上进行,本篇随笔要讲解的也是如何配置一个 ...

  3. “耐撕”团队 2016.04.08 站立会议

    1. 时间 : 15:20--15:40 2. 人员 : Z 郑蕊 * 组长 (博客:http://www.cnblogs.com/zhengrui0452/), P 濮成林(博客:http://ww ...

  4. HTML DOM 基础

    $. HTML DOM 定义了访问和操作 HTML 文档的标准方法.  DOM 是 W3C(万维网联盟)的标准. $. DOM树. $. W3C 文档对象模型 (DOM) 是中立于平台和语言的接口,它 ...

  5. 图书封面制作-ps图片处理使用教程

    这是一个实用而有趣的教程,在这个PS教程中,我们来学习如何使用photoshop制作一个立体的软件产品盒子. 1.首先运行photoshop创建一个500*500像素的新文件,背景颜色为白色,如图所示 ...

  6. ansible 使用方法

    免密钥方式登陆: [root@yizhen ~]# ssh-keygen -t rsa[root@yizhen ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168 ...

  7. hdu1588 矩阵快速幂

    //看了很多的博客 后来队友指点才懂//sum=f(g(0))+f(g(1))+.... //sum=A^(b-1)*|...|.... //要将b-1换,防止出现b=0时有负一,用A^b代替,取下面 ...

  8. Java基础-JVM类加载机制

    JVM的类加载是通过ClassLoader及其子类来完成的,类的层次关系和加载顺序可以由下图来描述: 1)Bootstrap ClassLoader /启动类加载器 $JAVA_HOME中jre/li ...

  9. Hession矩阵与牛顿迭代法

    1.求解方程. 并不是所有的方程都有求根公式,或者求根公式很复杂,导致求解困难.利用牛顿法,可以迭代求解. 原理是利用泰勒公式,在x0处展开,且展开到一阶,即f(x) = f(x0)+(x-x0)f' ...

  10. 配置hibernate

    http://blog.csdn.net/hanjiancanxue_liu/article/details/9966423