不兼容的C类错误? [英] incompatible type C error?
本文介绍了不兼容的C类错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
uint32 InterruptLatency;
uint8 measurements[32];
char buf[256];
int kernelinterrupt time()
{
fscanf(fp,"%lu", InterruptLatency); // I am reading the data from kernel which is not shown here
measurements[17] = InterrupLatency;
buf = &measurements; // I am getting error here as below
// after storing it in buffer I am sending the data from but to another layer
}
错误:从类型UINT8(*)[32]
ERROR : incompatible type when assigning of type char[256] from type uint8 (*)[32]
可以有人帮助我如何解决这个问题?
could some one help me how to solve this ??
推荐答案
在c您不能分配数组。你必须明确地复制内存。
In C you cannot assign arrays. You have to copy the memory explicitly.
也许你想这样做:
memcpy(buf, measurements, sizeof(measurements));
但是你没有给什么你真正想做的事情的细节。
But you gave no details about what you actually want to do.
PS:您的的fscanf()
是错误的。它应该采取的变量,将持有的读取值的地址。
PS: Your fscanf()
is wrong. It should take the address of the variable that will hold the read value.
如果你使用 uint32_t的
你应该使用 SCNu32
的规范,从< inttypes.h>
,以确保你不打破东西:
And if you use uint32_t
you should use the SCNu32
specification, from <inttypes.h>
, to be sure that you do not break things:
fscanf(fp,"%"SCNu32, &InterruptLatency);
这篇关于不兼容的C类错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文