header file changes hack.h, decl.h/.c, system.h, wintty.h

- Move secondary preprocessor defines down further in config.h
so that they can be overridden via [platform]conf.h which is
included from global.h, specifically:
    LIVELOGFILE when LIVELOG is defined
    DUMPLOG_FILE when DUMPLOG is defined

- Minimize platform-specific, or compiler-specific code in hack.h and decl.h.

- reorganize src/decl.c to align with include/decl.h.

- a new header file cstd.h added, containing calls to C99
standard header files.

- hack.h, decl.h, and decl.c have been cleaned up and had code
moved so that things line up as follows:

     hack.h     defines values that are available to all
                NetHack source files, contains enums for use in all
                NetHack source files, and contains a number of
                struct definitions for use in all NetHack source files.
                It does not contain variable declarations or variable
                definitions.

     decl.h     contains the extern declarations for variables that
                are defined in decl.c. These variables are global and
                available to all NetHack source files. The location of
                the variables within decl.h was random, so give it some
                order for now.

     decl.c     contains the definition of the variables declared in
                decl.h, and initializes them where appropriate. The
                variable definitions are laid out in much the
                same order as their declarations in decl.h.

- wintty.h: There were some varying terminal-related prototypes in
system.h, and that was the only thing left that demanded that
system.h be included. Those have been replaced by an #include
<term.h> in include/wintty.h to get the more current (and hopefully
more correct) prototypes, rather than hardcoding them in NetHack
sources.

For edge-case platform compatiblity, there is no #include <term.h>
if the build defines NO_TERMCAP_HEADERS. In that case one set of
hardcoded prototypes is still used in include/wintty.h.

The added #include "term.h" is also bypassed for NO_TERMS builds (builds
that don't link to terminfo/termcap at all, but still present a tty
interface using platform or window-port specific functions to fulfill
the same role as that of terminfo/termcap).

- some scattered, unnecessary #include "integer.h" were removed from
various files, since that's always included in current NetHack-3.7
sources, either directly from config.h or indirectly from #include
"hack.h".

- system.h references removed.

- new cstd.h added; the #include "system.h" references in Makefiles
and project files (Xcode, visual studio), were replaced
with #include "cstd.h" references. A "make depends" is probably
warranted.

Also:

 - Use of <term.h>, which defines clear_screen() as a macro, conflicts
with an actual function with that name in win/tty/termcap.c. The most
straight-forward course of action was to rename the NetHack function,
and change the references to it, from clear_screen() to
term_clear_screen(), so that was done.
This commit is contained in:
nhmall
2023-04-05 11:49:09 -04:00
parent ddca5650ea
commit 2185d325c4
30 changed files with 1294 additions and 1223 deletions

View File

@@ -432,7 +432,7 @@ QUIETCC=0
# Nothing below this line should have to be changed.
#
# Other things that have to be reconfigured are in config.h,
# {unixconf.h, pcconf.h}, and possibly system.h
# {unixconf.h, pcconf.h}, and possibly cstd.h
# Add rule for possible cross-compiler
$(TARGETPFX)%.o : %.c
@@ -549,7 +549,7 @@ HACKINCL = align.h artifact.h artilist.h attrib.h botl.h \
permonst.h prop.h rect.h region.h sym.h defsym.h rm.h sp_lev.h \
spell.h sndprocs.h seffects.h sys.h system.h tcap.h timeout.h \
tradstdc.h trap.h unixconf.h vision.h vmsconf.h wintty.h wincurs.h \
winX.h winprocs.h wintype.h you.h youprop.h
winX.h winprocs.h wintype.h you.h youprop.h cstd.h
HSOURCES = $(HACKINCL) dgn_file.h
@@ -800,7 +800,7 @@ depend: ../sys/unix/depend.awk \
$(CONFIG_H): ../include/config.h ../include/config1.h ../include/patchlevel.h \
../include/tradstdc.h ../include/integer.h \
../include/global.h ../include/coord.h ../include/vmsconf.h \
../include/system.h ../include/nhlua.h ../include/unixconf.h \
../include/cstd.h ../include/nhlua.h ../include/unixconf.h \
../include/pcconf.h ../include/micro.h ../include/windconf.h \
../include/warnings.h ../include/fnamesiz.h
touch $(CONFIG_H)