What does "NEARDATA" mean in NetHack source code?

NetHack source code (written in C) has some things that 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; 

(line 9 of the engraving at http://nethackwiki.com/wiki/engrave.c#line9 )

 STATIC_PTR int NDECL(doprev_message); 

(on line 106 cmd.c at http://nethackwiki.com/wiki/cmd.c#line106 )

 STATIC_DCL char *NDECL(parse); 

(line 157 cmd.c)

Can someone explain to me what “NEARDATA”, “STATIC_VAR”, “STATIC_PTR” and “STATIC_DCL" are, as well as what they mean?

+4
source share
2 answers

I checked a little ... NEARDATA is defined in config1.h and is only used on the AmigaOS platform. In this case, this means that the data segment (where global and static variables are stored) is referenced by the compiler relative to the CPU register.

Specifies that STATIC_* also platform dependent.

Thus, these are all platform-specific things defined using the pre-processor #define construct to ensure that the source is built on different platforms.

+2
source

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

0
source

Source: https://habr.com/ru/post/1382002/


All Articles