错误:“正确”未在此范围内声明 pad.pvx*= -1; }
void move_paddle(PADDLE pad, bool alongX)
{
if(alongX!=TRUE)
{
if((pad.py+pad.length/2)>=B || (pad.py-pad.length/2)<=BB)
pad.pvx*= -1;
}
else if((pad.px+pad.length/2)>=A || (pad.py-pad.length/2)<=AA)
pad.pvx*= -1;
}
实际错误是什么? M无法打通。
void move_paddle(PADDLE pad, bool alongX)
{
if(alongX!=TRUE)
{
if((pad.py+pad.length/2)>=B || (pad.py-pad.length/2)<=BB)
pad.pvx*= -1;
}
else if((pad.px+pad.length/2)>=A || (pad.py-pad.length/2)<=AA)
pad.pvx*= -1;
}
What is the actual error ? M unable to get through.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
标准 C 语言中没有
TRUE
关键字。最有可能的是,这是您缺少的宏声明。从哪里获取它取决于您使用的编译器和库。如果找不到它的定义,将此代码放在 TRUE 的使用之前(在文件的开头,但在所有包含之后)将解决问题:There is no
TRUE
keyword in standard C language. Most probably, this is a macro declaration that you are missing. Where to get it depends on what compiler and libraries you are using. If you cannot find its definition, putting this code before the usage of TRUE (in the beginning of the file, but after all includes) will fix the problem:由于您使用的是
bool
数据类型,看起来您正在 C99 中使用stdbool.h
。如果是这种情况,那么您应该将TRUE
更改为true
,后者扩展为1
。Since you are using
bool
data type, looks like you are usingstdbool.h
in C99. If that is the case then you should changeTRUE
totrue
which expands to1
.我猜如果编译器说你的错误是 TRUE 没有在此范围内声明,那么这就是实际的错误。也许你应该定义 TRUE。另外,正如我在评论中指出的那样(在我查看标题之前),您最好甚至不要在此代码段中使用
TRUE
。与 C 中的TRUE
进行比较可能会导致难以调试的微妙错误。if (!alongX)
的意思就是你想说的,我发现它比if (alongX == FALSE)
更清楚。I'm guessing that if the compiler says your error is that TRUE is not declared in this scope, then that's the actual error. Maybe you should define TRUE. Also, as I pointed out in my comment (before I had looked at the title) you're probably better off not even using
TRUE
in this snippet anyway. Comparing vs.TRUE
in C is likely to lead to subtle errors that are hard to debug.if (!alongX)
means what you wanted to say, and I find it clearer thanif (alongX == FALSE)
.你应该在c中使用像int这样的东西而不是bool,只要它的值不是0它就是true,我会将其更改为
You should use something like an int instead of a bool in c, and as long as it's value ain't 0 it's true, I would change this to