【发布时间】:2015-12-29 16:44:22
【问题描述】:
下面是一个函数,该函数将被一个主程序调用。我的问题是,如果我不将 challInfo 声明为结构,则在编译时它将返回:
第 5 行第 21 列的 PhotoPoints 页出现错误:“challInfo”未在此范围内声明
同时,如果我声明它(如下所示),它会返回:
第 5 行第 30 列 PhotoPoints 页面上的错误:'.' 标记之前的预期主表达式 第 7 行第 7 列第 52 列 PhotoPoints 页面上的错误:第 8 行 PhotoPoints 页面上的预期主表达式错误, col 28: '.' 之前的预期主表达式第 8 行 PhotoPoints 页面上的令牌错误,col 60: '.' 之前的预期主表达式第 8 行 PhotoPoints 页面上的令牌错误,col 109: 之前的预期主表达式' .' 第 9 行第 31 列 PhotoPoints 页面上的令牌错误:第 9 行第 9 列 PhotoPoints 页面上的预期主表达式出现错误,第 118 列:第 14 行的 PhotoPoints 页上的预期主表达式错误,第 35 列:第 14 行的 PhotoPoints 页上的预期主表达式错误,第 57 列:预期的主表达式之前.' 令牌
我一直在浏览互联网,包括 Stack Overflow,似乎总是针对每种情况给出具体的答案。我承认我迷路了。你能帮忙吗?
float PhotoPoints() {
struct challInfo;
bool isFacingOther();
bool sphereInDark();
bool isCameraOn = challInfo.camera.cameraOn;
bool isFacingOtherResult = isFacingOther();
bool isOppNotInDarkZone = !sphereInDark(challInfo.other.zrState);
bool myMirror = challInfo.me.mirrorTime != 0 && challInfo.me.mirrorTime + ITEM_MIRROR_DURATION > challInfo.currentTime;
bool otherMirror = challInfo.other.mirrorTime != 0 && challInfo.other.mirrorTime + ITEM_MIRROR_DURATION > challInfo.currentTime;
float picturePointValue = 0;
if (isCameraOn && isFacingOtherResult && isOppNotInDarkZone && !myMirror)
{
float bet[3], distance;
mathVecSubtract(bet, challInfo.me.zrState, challInfo.other.zrState, 3);
distance = mathVecMagnitude(bet, 3);
if (distance < PHOTO_MIN_DISTANCE) {
DEBUG(("Not a good shot: too close to the other satellite | "));
return 0.0;
}
picturePointValue = 2.0 + 0.1/(distance - PHOTO_MIN_DISTANCE + 0.1);
if(otherMirror){
picturePointValue = 0;
DEBUG(("Not a good shot: Opposing mirror active |"));
}
}
else if(!isCameraOn){
DEBUG(("Not a good shot: camera off |"));
}
else if(myMirror){
DEBUG(("Not a good shot: my mirror's in the way |"));
}
else if(!isFacingOtherResult) {
DEBUG(("Not a good shot: not facing the other satellite | "));
}
else if(!isOppNotInDarkZone){
DEBUG(("Not a good shot: opponent in dark zone |"));
}
return picturePointValue;
}
【问题讨论】:
-
struct challInfo似乎缺少类型名称。或者,如果challInfo是一个结构类型,它缺少变量名和结构的定义。 -
我怕没跟上,怎么改?
-
其他人不可能猜到如何纠正它,但我怀疑该函数应该有一个名为“challInfo”的参数,无论它应该是什么类型。
-
您接受答案了吗? @NunoViegas
-
请去掉'mysql'标签;似乎无关。