OoO*_*OoO -2 c linux pointers casting compiler-errors
我已经尝试了*和s的所有可能组合.我无法弄清楚这个程序有什么问题以及导致这个编译时错误的原因
我收到这个错误:
error: initialization makes pointer from integer without a cast
compilation terminated due to -Wfatal-errors.
Run Code Online (Sandbox Code Playgroud)
使用此代码:
int main() {
unsigned int ten = (int) 10;
unsigned short *a = (short) 89;
unsigned int *p =(int) 1;
unsigned short *q = (short) 10;
unsigned short *s = (short) 29;
function(ten,a,p, q, s);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
功能原型是:
int function(unsigned int a, unsigned short *const b,
unsigned int *const c,
unsigned short *const d,
unsigned short *const e);
Run Code Online (Sandbox Code Playgroud)
该函数为空,我只是想用输入文件编译它.
小智 5
这些变量是指针,您尝试为它们分配整数(短)值:
unsigned short *a = (short) 89;
unsigned int *p =(int) 1;
unsigned short *q = (short) 10;
unsigned short *s = (short) 29;
Run Code Online (Sandbox Code Playgroud)
这就是你得到编译器错误的原因.
问题不是100%明确,但也许这就是你想要的:
unsigned int ten = (int) 10;
unsigned short a = (short) 89;
unsigned int p =(int) 1;
unsigned short q = (short) 10;
unsigned short s = (short) 29;
function(ten, &a, &p, &q, &s);
Run Code Online (Sandbox Code Playgroud)