如何修复错误"long* is incompatible with U32**"?

How to fix error "long* is incompatible with U32**"?

本文关键字:with U32 incompatible 错误 long 何修复 is      更新时间:2023-10-16

我尝试调用具有以下签名的函数:

I32 contour8(image *a, I32 x0, I32 y0, I32 dir, I32 thr, U32 lng, U32 **dst);

使用此代码:

int posx = 100, posy = 100, dx = 300, dy = 300;
long length = 5000;
int threshold = 125;
int lx, x0 = 0, y0 = 0;
int res1 = 0, res2 = 0, *rlc, *input, i;
long dest1, dest2, desttemp, addr;
char c;
image Area;
desttemp = dest1;
res1 = contour8(&Area, x0, y0, ~2, threshold, length, &desttemp);

但是在编译时出现以下错误:

error argument of type "long *" is incompatible with parameter of type "U32 **"

导致此错误的原因是什么?

您的变量desttemp的类型为 long&desttemp 会产生您尝试作为参数dst传递给contour8long*,该参数的类型为 U32**

long*不能隐式转换为U32**,这会导致您的错误。

您应该将desttemp设为U32*(推荐(,或者将&desttemp转换为U32**(不推荐;只要您不知道自己在做什么,这就会引入其他问题(。由于我们不知道您的函数的作用/期望,因此您最终需要自己决定哪一个最适合您的情况。

在 32 位系统中,长变量的大小为 64 位。因此,您可能会在 64 个变量中传递 32 位值,从而获得错误。此外,一个简单的建议总是在声明期间初始化所有变量,你没有初始化一些变量和指针,作为一个程序员,这被认为是不好的做法。干杯。。:)