简体   繁体   English

给函数提供地址时,Xcode中出现预期的')'错误

[英]expected ')' error in Xcode when giving an address to function

There is a little arrow under the "&" and if I remove it, it works. 在“&”下方有一个小箭头,如果我将其删除,它将起作用。 Im new to Xcode and i'm pretty sure this would compile on my old PC. 我是Xcode的新手,我很确定这可以在旧PC上编译。 I had previous declared in the code booth the struct and the variable barra. 我之前曾在代码亭中声明过struct和变量barra。

void InitBarra(struct Barra &barra)
{
    barra.x = WIDTH/2;
    barra.y = HEIGHT;
    barra.vidas = 3;
    barra.velocidade = 7;
    barra.placar = 0;
}

This really should be a pointer: 这确实应该是一个指针:

void InitBarra(Barra *barra)
{
    barra->x = WIDTH/2;
    barra->y = HEIGHT;
    barra->vidas = 3;
    barra->velocidade = 7;
    barra->placar = 0;
}

Where the Barra struct is declared and/or malloc'd from the calling function. 在调用函数中声明和/或分配了Barra结构的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM