“NEARDATA”是什么意思? NetHack源代码中的意思是什么?
NetHack源代码(用C编写)有一些我不明白的东西。
以下代码可以在 Nethack 3.4.3 源代码中找到:(
STATIC_VAR NEARDATA struct engr *head_engr;
位于 engrave.c 的第 9 行,位于 http://nethackwiki.com/wiki/engrave.c#line9)
STATIC_PTR int NDECL(doprev_message);
(cmd.c 第 106 行,位于 http://nethackwiki.com/wiki/cmd.c#line106)
STATIC_DCL char *NDECL(parse);
(第 157 行cmd.c)
有人可以向我解释一下“NEARDATA”、“STATIC_VAR”、“STATIC_PTR”和“STATIC_DCL”是什么,以及它们的含义吗?
The NetHack source code (written in C) has some things I don't understand.
The following code can be found in the Nethack 3.4.3 source code:
STATIC_VAR NEARDATA struct engr *head_engr;
(on line 9 of engrave.c at http://nethackwiki.com/wiki/engrave.c#line9)
STATIC_PTR int NDECL(doprev_message);
(on line 106 of cmd.c at http://nethackwiki.com/wiki/cmd.c#line106)
STATIC_DCL char *NDECL(parse);
(on line 157 of cmd.c)
Could someone please explain to me what "NEARDATA", "STATIC_VAR", "STATIC_PTR" and "STATIC_DCL" are, and also what they mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我做了一些检查...
NEARDATA
是在config1.h
中定义的,并且仅在 AmigaOS 平台上使用。在这种情况下,这意味着数据段(存储全局变量和静态变量)由编译器相对于 CPU 寄存器引用。STATIC_*
定义似乎也依赖于平台。因此,这都是特定于平台的东西,使用预处理器#define 构造来定义,以确保源代码构建在不同的平台上。
I did a little checking...
NEARDATA
is defined inconfig1.h
, and is only used on the AmigaOS platform. In this case it means that the data segment (where global and static variables are stored), is referenced by the compiler relative to a CPU register.The
STATIC_*
defines also seem to be platform dependent.So this is all platform-specific things, defined using the pre-processor
#define
construct, to make sure that the source builds on the different platforms.它们是 预处理器 宏,并在 hack.h 包含在这些文件的顶部。
They are pre-processor macros, and are defined in hack.h which is included at the top of those files.