加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

delphi – 为什么这个C到Pascal转换崩溃?

发布时间:2020-12-15 09:39:13 所属栏目:大数据 来源:网络整理
导读:我有这个C代码: /* WARNING: The order of this table must also match the order of a table located in AcquireResizeFilter() in "resize.c" otherwise the users filter will not match the actual filter that is setup.*/typedef enum{ UndefinedFilt
我有这个C代码:

/*
  WARNING:  The order of this table must also match the order of a table
  located in AcquireResizeFilter() in "resize.c" otherwise the users filter
  will not match the actual filter that is setup.
*/
typedef enum
{
  UndefinedFilter,PointFilter,BoxFilter,TriangleFilter,HermiteFilter,HannFilter,HammingFilter,BlackmanFilter,GaussianFilter,QuadraticFilter,CubicFilter,CatromFilter,MitchellFilter,JincFilter,SincFilter,SincFastFilter,KaiserFilter,WelchFilter,ParzenFilter,BohmanFilter,BartlettFilter,LagrangeFilter,LanczosFilter,LanczosSharpFilter,Lanczos2Filter,Lanczos2SharpFilter,RobidouxFilter,RobidouxSharpFilter,CosineFilter,SplineFilter,LanczosRadiusFilter,CubicSplineFilter,SentinelFilter  /* a count of all the filters,not a real filter */
} FilterType;

WandExport MagickBooleanType MagickResizeImage(MagickWand *wand,const size_t columns,const size_t rows,const FilterType filter)

我将它转换为Pascal,如下所示:

type
  FilterType =(
    UndefinedFilter,SentinelFilter);  // a count of all the filters,not a real filter

function MagickResizeImage(wand: PMagickWand; const columns: size_t; rows: size_t; const filter: FilterType): MagickBooleanType; cdecl; external MagickWandDLL;

当我调用MagickResizeImage()时,我收到了访问冲突:(

如果我改变const过滤器:FilterType到const过滤器:整数,它的工作原理.

知道我做错了什么吗?

解决方法

在Windows上的C中,枚举是一个int,因此大小为4个字节.在Delphi中,默认情况下,它是一个单字节,如果有超过256个值,则为两个字节,依此类推.

您需要确保您的Delphi类型与C类型相同.例如,使用MINENUMSIZE指令.

{$MINENUMSIZE 4}

在定义枚举类型之前放置它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读