magic.plane
magic.plane

Reputation: 61

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?

Upvotes: 5

Views: 451

Answers (2)

Some programmer dude
Some programmer dude

Reputation: 409356

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.

Upvotes: 3

Brian Roach
Brian Roach

Reputation: 76908

They are pre-processor macros, and are defined in hack.h which is included at the top of those files.

Upvotes: 0

Related Questions