如何修复错误"long*与U32**不兼容"?

use*_*838 -1 c c++ type-conversion

我尝试使用以下签名调用函数:

I32 contour8(image *a, I32 x0, I32 y0, I32 dir, I32 thr, U32 lng, U32 **dst);
Run Code Online (Sandbox Code Playgroud)

使用此代码:

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);
Run Code Online (Sandbox Code Playgroud)

但是在编译时我得到以下错误:

error argument of type "long *" is incompatible with parameter of type "U32 **"
Run Code Online (Sandbox Code Playgroud)

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

Max*_*uxa 7

你的变量desttemp是类型的long.&desttemp结果long*你试图传递给contour8作为参数,dst它的类型的U32**.

long*是不可隐式转换为U32**导致错误的.

你要么做desttemp一个U32*(推荐),或投&desttempU32**(不推荐;只要这会引入其他问题,因为你不知道你在做什么).因为我们不知道你的功能是什么/期望你最终需要自己决定哪一个最适合你的情况.