首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ca65:包含保护生成“错误:预期标识符”

ca65:包含保护生成“错误:预期标识符”
EN

Stack Overflow用户
提问于 2019-10-22 18:46:36
回答 1查看 448关注 0票数 5

为了学习如何使用ca65汇编程序,我一直在努力使包括警卫工作。谷歌和阅读“ca65用户指南”没有帮助。下面是一个生成错误的最小示例。

代码语言:javascript
复制
$ ls -l
total 16
-rw-r--r--  1 me  staff  60 Oct 22 19:40 65.inc
-rw-r--r--  1 me  staff  55 Oct 22 20:01 test.s
$
$ cat 65.inc
.ifndef _65_INC_
.define _65_INC_

.define NUMBER 1

.endif
$
$ cat test.s
.include "65.inc"
.include "65.inc"

    lda #NUMBER
    rts
$
$ ca65 test.s
65.inc(1): Error: Identifier expected
65.inc(2): Error: Identifier expected
65.inc(4): Error: Identifier expected
65.inc(4): Note: Macro was defined here
$
$ ls -l
total 16
-rw-r--r--  1 me  staff  60 Oct 22 19:40 65.inc
-rw-r--r--  1 me  staff  55 Oct 22 20:01 test.s
$

如果我只在65.inc中包含一次test.s,那么它就没有问题地组装了,如下所示:

代码语言:javascript
复制
$ ls -l
total 16
-rw-r--r--  1 me  staff  60 Oct 22 19:40 65.inc
-rw-r--r--  1 me  staff  37 Oct 22 20:07 test.s
$
$ cat 65.inc
.ifndef _65_INC_
.define _65_INC_

.define NUMBER 1

.endif
$
$ cat test.s
.include "65.inc"

    lda #NUMBER
    rts
$
$ ca65 test.s
$
$ ls -l
total 24
-rw-r--r--  1 me  staff   60 Oct 22 19:40 65.inc
-rw-r--r--  1 me  staff  295 Oct 22 20:07 test.o
-rw-r--r--  1 me  staff   37 Oct 22 20:07 test.s
$
$ ca65 --version
ca65 V2.17 - Git 153bb29

我遗漏了什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-22 19:20:16

有些令人困惑的是,.ifndef和朋友应用于符号,而这些宏不是(.define定义宏)。因此,一个可能的解决办法是使用一个符号。

代码语言:javascript
复制
.ifndef _65_INC_
_65_INC_ = 1

.define NUMBER 1

.endif
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58510587

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档