我正在尝试在 C 中为 Game Boy Advance 创建一个 1bpp 位图字体,本质上我想创建一个由 (ASCII CODE - 32)*8 索引的连续 ROM 数据区域。到目前为止,我收到了我不明白的错误消息。
错误:
C:/Users/puppy/Documents/ARMDevTools/SrcGBA/PaintBoyAdvance/source/paintboyadvance.c:35:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
35 | bitmapfont[0].pixelsPerLetter[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
| ^
C:/Users/puppy/Documents/ARMDevTools/SrcGBA/PaintBoyAdvance/source/paintboyadvance.c:36:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token
36 | bitmapfont[1].pixelsPerLetter[] = {0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x00};
| ^
================ READY ================
导致错误的源代码(最小可重现示例):
struct letter{
char PixelsPerLetter[8];
};
struct letter bitmapfont[96];
bitmapfont[0].PixelsPerLetter[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
bitmapfont[1].PixelsPerLetter[] = {0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x00};
int main(void)
{
return 0;
}
据我所知,我在行尾没有遗漏任何分号,所以我不明白为什么我什至需要列出的字符。这就是你在数组中定义每个结构的方式,不是吗?有这样的点?这就是我看到的所有示例所显示的,但我得到了这个错误。
编辑:将所有内容移入 main 会给我一个不同的错误:
C:/Users/puppy/Documents/ARMDevTools/SrcGBA/PaintBoyAdvance/source/paintboyadvance.c:12:39: error: expected expression before ']' token
12 | bitmapfont[0].PixelsPerLetter[] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
| ^
C:/Users/puppy/Documents/ARMDevTools/SrcGBA/PaintBoyAdvance/source/paintboyadvance.c:13:39: error: expected expression before ']' token
13 | bitmapfont[1].PixelsPerLetter[] = {0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x00};
这个我也看不懂