Search code examples
cnethack

What does "NEARDATA" mean in the NetHack source code?


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?


Solution

  • I did a little checking... NEARDATA is defined in config1.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.