【发布时间】:2019-12-24 17:53:54
【问题描述】:
编译以下代码时出现以下错误:
sccz80:"../lib/main.c" L:16 Warning:#14:Expected ','
sccz80:"../lib/main.c" L:16 Error:#28:Segmentation fault
/*
* A test game of Pong using the Z88dk
*/
#include <spectrum.h>
#include <graphics.h>
#include <sprites/sp1.h>
#include <stdio.h>
struct Bat {
int x;
int y;
int w;
int h;
};
void clear_screen(Bat* bat)
{
undrawb(bat.x, bat.y, bat.w, bat.h);
}
int main()
{
struct Bat bat;
bat.x = 0;
bat.y = 0;
bat.w = 8;
bat.h = 24;
while(1)
{
zx_border(INK_GREEN);
clear_screen(&bat);
drawb(bat.x, bat.y, bat.w, bat.h);
}
return 0;
}
关于可能是什么问题的任何建议?我正在使用 z88dk 创建一个测试 ZX Spectrum 程序。不幸的是,我没有足够高的分数来添加“z88dk”标签。对此深表歉意。
【问题讨论】:
-
尝试预处理它,看看你得到了什么;
h变量的某些内容似乎让编译器感到困惑。 -
@LightnessRacesBY-SA3.0 你介意让我快速了解一下你的意思吗?我不确定我需要定义什么。
-
在函数
clear_screen中使用未定义的类型Bat。然后你定义了一个指针bat,但是当你访问那个未知结构的字段时,你使用.而不是->。这无法编译。 -
@Gerhardh 谢谢,那行得通。我真的需要在 Atom 中安装一些语法检查。
-
@Gerhardh 奇怪的编译器对此进行了段错误
标签: c linux zxspectrum