USE_OLDARGS update (1 of 2)

Files modified:
    include/tradstdc.h, sp_lev.h, system.h
    util/lev_main.c

Silence a bunch of warnings generated by recent gcc which weren't there
with whatever version I had when 3.6.0 was being readied for release.
For lev_main, there were two basic types:  not enough arguments in calls
to lc_pline, lc_warning, and lc_error (since we weren't passing dummy
arguments as is done for add_opvars), and conversion from 'int' or
narrower to 'char *' (from -Wint-to-pointer-cast, which either wasn't
there yet in the older gcc, or wasn't included in -Wall back then).
[Note that for any configuration decrepit enough to actually need
USE_OLDARGS, such conversions will either work fine or else nethack
simply won't be viable.]

src/pline.c generates a bunch of warnings (for USE_OLDARGS).  The fix
for that will be (2 of 2).

To test, instead of mucking about with CFLAGS or sys/unix/hints, I've
been temporarily adding unconditional
|#undef USE_STDARG
|#undef USE_VARARGS
|#define USE_OLDARGS
to the end of config1.h and then doing my normal build--which is why
-Wall (or possibly -W) is drawing -Wint-to-pointer-cast warnings.
This commit is contained in:
PatR
2017-08-02 18:23:42 -07:00
parent b4e4d70008
commit 64f284dd61
4 changed files with 100 additions and 80 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 tradstdc.h $NHDT-Date: 1448210011 2015/11/22 16:33:31 $ $NHDT-Branch: master $:$NHDT-Revision: 1.27 $ */
/* NetHack 3.6 tradstdc.h $NHDT-Date: 1501723401 2017/08/03 01:23:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.28 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -128,15 +128,23 @@
#else
/*USE_OLDARGS*/
/*
* CAVEAT: passing double (including float promoted to double) will
* almost certainly break this, as would any integer type bigger than
* sizeof (char *).
* NetHack avoids floating point, and any configuration able to use
* 'long long int' or I64P32 or the like should be using USE_STDARG.
*/
#ifndef VA_TYPE
typedef const char *vA;
#define VA_TYPE
#endif
#define VA_ARGS arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9
#define VA_DECL(typ1, var1) \
(var1, VA_ARGS) typ1 var1; \
char *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8, *arg9; \
(var1, VA_ARGS) typ1 var1; vA VA_ARGS; \
{
#define VA_DECL2(typ1, var1, typ2, var2) \
(var1, var2, VA_ARGS) typ1 var1; \
typ2 var2; \
char *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7, *arg8, *arg9; \
(var1, var2, VA_ARGS) typ1 var1; typ2 var2; vA VA_ARGS; \
{
#define VA_START(x)
#define VA_INIT(var1, typ1)
@@ -151,7 +159,7 @@
*/
#define VA_SHIFT() \
(arg1 = arg2, arg2 = arg3, arg3 = arg4, arg4 = arg5, arg5 = arg6, \
arg6 = arg7, arg7 = arg8, arg8 = arg9)
arg6 = arg7, arg7 = arg8, arg8 = arg9, arg9 = 0)
#define VA_NEXT(var1, typ1) ((var1 = (typ1) arg1), VA_SHIFT(), var1)
#define VA_END() }
#endif
@@ -380,7 +388,7 @@ typedef genericptr genericptr_t; /* (void *) or (char *) */
* append this to a prototype declaration (see pline() in extern.h).
*/
#ifdef __GNUC__
#if __GNUC__ >= 2
#if (__GNUC__ >= 2) && !defined(USE_OLDARGS)
#define PRINTF_F(f, v) __attribute__((format(printf, f, v)))
#endif
#if __GNUC__ >= 3