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. 【Aaronyang原创】用linq取出一个集合中重复的数据

    文章已经迁移:http://www.ayjs.net/2013/07/69/ 文章已经迁移:http://www.ayjs.net/2013/07/69/ 文章已经迁移:http://www.ayjs ...

  2. 图解NodeJS【基于事件、回调的单线程高性能服务器】原理

    刚开始了解Node感觉很吊,各种说高性能,可是一直不理解为什么单线程会比多线程快?为什么异步IO比非阻塞IO快?因此,本篇在阅读相关书籍后,根据自己的理解,整理此文,如有错误,仅代表理论不精,必当修改 ...

  3. NIO提升系统性能

    前言 在软件系统中,I/O的速度要比内存的速度慢很多,因此I/O经常会称为系统的瓶颈.所有,提高I/O速度,对于提升系统的整体性能有很大的作用. 在java标准的I/O中,是基于流的I/O的实现,即I ...

  4. u1-nav-css

    header:before, header:after ,.navigation:before, .navigation:after,.nav-row:before, .nav-row:after,. ...

  5. hdu2923 最短路floyd

    建图还是有点烦人的. #include<map> #include<string> #include<stdio.h> #include<iostream&g ...

  6. strncmp很好的函数

    strcmp比较的是所有的长度,而strncmp可以比较前几个长度 strncmp(s1,s2,n);这样就比较了s1,s2,前n个长度的大小.

  7. TinyMCE(富文本编辑器)

    [转]TinyMCE(富文本编辑器)在Asp.Net中的使用方法 官网演示以及示例代码:https://www.tinymce.com/docs/demo/image-tools/ 转自:http:/ ...

  8. LinkedHashMap实现LRU算法

    LinkedHashMap特别有意思,它不仅仅是在HashMap上增加Entry的双向链接,它更能借助此特性实现保证Iterator迭代按照插入顺序(以insert模式创建LinkedHashMap) ...

  9. Fedora21下安装cuda7.5

    Fedora21装cuda7.5 首先制作启动U盘.装好fedora21后别做任何update等yum和rpm操作,按照下面步骤走. 其中遇到用UEFI模式安装cuda时,系统一定要求提供公钥和私钥, ...

  10. HDU-1394 Minimum Inversion Number 线段树+逆序对

    仍旧在练习线段树中..这道题一开始没有完全理解搞了一上午,感到了自己的shabi.. Minimum Inversion Number Time Limit: 2000/1000 MS (Java/O ...