new file: include/lint.h
modified files: include/hack.h, src/decl.c, sys/unix/Makefile.src Groundwork for cleaning up the X11 sources, where gcc with the option settings specified in the OSX hints file currently generates close to 400 warnings for win/X11/*.c. lint.h is included by hack.h, and I've moved the debugpline stuff from the latter to the former to hide it better. (By rights it belongs in debug.h or something of the sort, but I didn't want to go that far.) Makefile and project dependencies need to catch up. nhStr() hides a cast to char *, and is intended to by used on string literals where it isn't feasible to maintain the 'const' attribute. (A pernicious problem with X11 code, where the include situation can become very convoluted, and many, MANY string literals are hidden behind macros to look like keyword-type tokens.) nhUse() can be used to force a fake usage on something which triggers an unused parameter warning. There are a 6 or 8 or 10 places in the core code where that applies, but so far I have't touched any of them. There's a tradeoff since it will result in some worthless code being generated and executed, but is much simpler than tacking on compiler- specific workarounds like '#pragma unused' or gcc's __attribute__ hack.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 hack.h $NHDT-Date: 1426465431 2015/03/16 00:23:51 $ $NHDT-Branch: debug $:$NHDT-Revision: 1.52 $ */
|
||||
/* NetHack 3.5 hack.h $NHDT-Date: 1430897858 2015/05/06 07:37:38 $ $NHDT-Branch: master $:$NHDT-Revision: 1.59 $ */
|
||||
/* NetHack 3.5 hack.h $Date: 2009/05/06 10:44:46 $ $Revision: 1.49 $ */
|
||||
/* SCCS Id: @(#)hack.h 3.5 2008/03/19 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
@@ -10,23 +10,7 @@
|
||||
#ifndef CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
/* [DEBUG shouldn't be defined unless you know what you're doing...] */
|
||||
#ifdef DEBUG
|
||||
# define ifdebug(stmt) do { if (showdebug(__FILE__)) stmt; } while (0)
|
||||
/* these don't require compiler support for C99 variadic macros */
|
||||
# define debugpline0(str) ifdebug(pline(str))
|
||||
# define debugpline1(fmt,arg) ifdebug(pline(fmt,arg))
|
||||
# define debugpline2(fmt,a1,a2) ifdebug(pline(fmt,a1,a2))
|
||||
# define debugpline3(fmt,a1,a2,a3) ifdebug(pline(fmt,a1,a2,a3))
|
||||
# define debugpline4(fmt,a1,a2,a3,a4) ifdebug(pline(fmt,a1,a2,a3,a4))
|
||||
#else
|
||||
# define debugpline0(str) /*empty*/
|
||||
# define debugpline1(fmt,arg) /*empty*/
|
||||
# define debugpline2(fmt,a1,a2) /*empty*/
|
||||
# define debugpline3(fmt,a1,a2,a3) /*empty*/
|
||||
# define debugpline4(fmt,a1,a2,a3,a4) /*empty*/
|
||||
#endif /*DEBUG*/
|
||||
#include "lint.h"
|
||||
|
||||
#define TELL 1
|
||||
#define NOTELL 0
|
||||
|
||||
52
include/lint.h
Normal file
52
include/lint.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* NetHack 3.5 lint.h $NHDT-Date: 1430897871 2015/05/06 07:37:51 $ $NHDT-Branch: master $:$NHDT-Revision: 1.0 $ */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/*
|
||||
* Hacks to suppress compiler warnings. Use with caution.
|
||||
* Assumes it has been preceded by '#include "config.h"' but
|
||||
* not necessarily by '#include "hack.h"'.
|
||||
*/
|
||||
#ifndef LINT_H
|
||||
#define LINT_H
|
||||
|
||||
/* cast away implicit const from a string literal (caller's responsibility
|
||||
to ensure that) in order to avoid a warning from 'gcc -Wwrite-strings'
|
||||
(also caller's responsibility to ensure it isn't actually modified!) */
|
||||
#define nhStr(str) ((char *)str)
|
||||
|
||||
#if defined(GCC_WARN) && !defined(FORCE_ARG_USAGE)
|
||||
# define FORCE_ARG_USAGE
|
||||
#endif
|
||||
|
||||
#ifdef FORCE_ARG_USAGE
|
||||
/* force an unused function argument to become used in an arbitrary
|
||||
manner in order to suppress warning about unused function arguments;
|
||||
viable for scalar and pointer arguments */
|
||||
# define nhUse(arg) nhUse_dummy += (unsigned)arg;
|
||||
extern unsigned nhUse_dummy;
|
||||
#else
|
||||
# define nhUse(arg) /*empty*/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This stuff isn't related to lint suppression but lives here to
|
||||
* avoid cluttering up hack.h.
|
||||
*/
|
||||
/* [DEBUG shouldn't be defined unless you know what you're doing...] */
|
||||
#ifdef DEBUG
|
||||
# define ifdebug(stmt) do { if (showdebug(__FILE__)) stmt; } while (0)
|
||||
/* these don't require compiler support for C99 variadic macros */
|
||||
# define debugpline0(str) ifdebug(pline(str))
|
||||
# define debugpline1(fmt,arg) ifdebug(pline(fmt,arg))
|
||||
# define debugpline2(fmt,a1,a2) ifdebug(pline(fmt,a1,a2))
|
||||
# define debugpline3(fmt,a1,a2,a3) ifdebug(pline(fmt,a1,a2,a3))
|
||||
# define debugpline4(fmt,a1,a2,a3,a4) ifdebug(pline(fmt,a1,a2,a3,a4))
|
||||
#else
|
||||
# define debugpline0(str) /*empty*/
|
||||
# define debugpline1(fmt,arg) /*empty*/
|
||||
# define debugpline2(fmt,a1,a2) /*empty*/
|
||||
# define debugpline3(fmt,a1,a2,a3) /*empty*/
|
||||
# define debugpline4(fmt,a1,a2,a3,a4) /*empty*/
|
||||
#endif /*DEBUG*/
|
||||
|
||||
#endif /* LINT_H */
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.5 decl.c $NHDT-Date$ $NHDT-Branch$:$NHDT-Revision$ */
|
||||
/* NetHack 3.5 decl.c $NHDT-Date: 1430897862 2015/05/06 07:37:42 $ $NHDT-Branch: master $:$NHDT-Revision: 1.56 $ */
|
||||
/* NetHack 3.5 decl.c $Date: 2012/04/09 02:56:30 $ $Revision: 1.37 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -331,6 +331,9 @@ NEARDATA struct savefile_info sfrestinfo, sfsaveinfo = {
|
||||
char *ARGV0;
|
||||
#endif
|
||||
|
||||
/* support for lint.h */
|
||||
unsigned nhUse_dummy = 0;
|
||||
|
||||
/* dummy routine used to force linkage */
|
||||
void
|
||||
decl_init()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# NetHack Makefile.
|
||||
# NetHack 3.5 Makefile.src $NHDT-Date: 1428590253 2015/04/09 14:37:33 $ $NHDT-Branch: scshunt-regex $:$NHDT-Revision: 1.38 $
|
||||
# NetHack 3.5 Makefile.src $NHDT-Date: 1430897864 2015/05/06 07:37:44 $ $NHDT-Branch: master $:$NHDT-Revision: 1.39 $
|
||||
# NetHack 3.5 Makefile.src $Date: 2012/01/20 03:41:33 $ $Revision: 1.37 $
|
||||
|
||||
# Root of source tree:
|
||||
@@ -369,7 +369,8 @@ CSOURCES = $(HACKCSRC) $(SYSCSRC) $(WINCSRC) $(CHAINSRC) $(GENCSRC)
|
||||
HACKINCL = align.h amiconf.h artifact.h artilist.h attrib.h beconf.h botl.h \
|
||||
color.h config.h config1.h context.h coord.h decl.h def_os2.h \
|
||||
display.h dlb.h dungeon.h engrave.h extern.h flag.h func_tab.h \
|
||||
global.h hack.h lev.h macconf.h mextra.h mfndpos.h micro.h mkroom.h \
|
||||
global.h hack.h lev.h lint.h macconf.h mextra.h mfndpos.h micro.h \
|
||||
mkroom.h \
|
||||
monattk.h mondata.h monflag.h monst.h monsym.h obj.h objclass.h \
|
||||
os2conf.h patchlevel.h pcconf.h permonst.h prop.h rect.h region.h rm.h \
|
||||
sp_lev.h spell.h sys.h system.h tcap.h timeout.h tosconf.h tradstdc.h \
|
||||
@@ -572,7 +573,7 @@ $(CONFIG_H): ../include/config.h ../include/config1.h ../include/tradstdc.h \
|
||||
../include/wceconf.h ../include/ntconf.h
|
||||
touch $(CONFIG_H)
|
||||
# hack.h timestamp
|
||||
$(HACK_H): ../include/hack.h $(CONFIG_H) ../include/align.h \
|
||||
$(HACK_H): ../include/hack.h $(CONFIG_H) ../include/lint.h ../include/align.h \
|
||||
../include/dungeon.h ../include/monsym.h ../include/mkroom.h \
|
||||
../include/objclass.h ../include/youprop.h ../include/prop.h \
|
||||
../include/permonst.h ../include/monattk.h \
|
||||
@@ -624,7 +625,7 @@ topl.o: ../win/tty/topl.c $(HACK_H) ../include/tcap.h
|
||||
wintty.o: ../win/tty/wintty.c $(HACK_H) ../include/dlb.h ../include/tcap.h
|
||||
$(CC) $(CFLAGS) -c ../win/tty/wintty.c
|
||||
Window.o: ../win/X11/Window.c ../include/xwindowp.h ../include/xwindow.h \
|
||||
$(CONFIG_H)
|
||||
$(CONFIG_H) ../include/lint.h
|
||||
$(CC) $(CFLAGS) -c ../win/X11/Window.c
|
||||
dialogs.o: ../win/X11/dialogs.c $(CONFIG_H)
|
||||
$(CC) $(CFLAGS) -c ../win/X11/dialogs.c
|
||||
|
||||
Reference in New Issue
Block a user