function pointer assignment warnings in VC2005

The latest Micrsoft compilers complain when a function is
assigned to a function pointer, and the function's argument
list does not match the prototype precisely.
It was evem complaining about the difference between this:
     int x()
     {
        [...]
     }
and a prototype of
     int x(void);
when assigning that function's address to a function pointer.

This quiets those warnings, without suppressing the mismatch
check altogether for more serious mismatches.
This commit is contained in:
nethack.allison
2006-06-25 19:54:31 +00:00
parent c374583632
commit d09c374239
11 changed files with 109 additions and 91 deletions

View File

@@ -120,6 +120,24 @@ typedef xchar boolean; /* 0 or 1 */
#define MONST_P struct monst*
#endif
#if defined(WIN32) && defined(_MSC_VER)
/* Microsoft Visual C 2005 (_MSC_VER > 1000) complains if a
* function pointer prototype is
* int x(void);
* via the NDECL macro, but the actual function assigned has a definition
* int x()
* {
* }
* We can quiet this by changing the function definition like so
* int x(VOID_ARGS)
* {
* }
*/
#define VOID_ARGS void
#else
#define VOID_ARGS
#endif
#define SIZE(x) (int)(sizeof(x) / sizeof(x[0]))

View File

@@ -318,29 +318,29 @@ bot()
/* If entries are added to this, botl.h will require updating too */
struct istat_s blstats[2][MAXBLSTATS] = {
{
{ 0L, ANY_STR, {(long)0L}, (char *)0, 80, 0 }, /* 0 BL_TITLE */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 1 BL_STR */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 2 BL_DX */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 3 BL_CO */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 4 BL_IN */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 5 BL_WI */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 6 BL_CH */
{ 0L, ANY_STR, {(long)0L}, (char *)0, 40, 0}, /* 7 BL_ALIGN */
{ 0L, ANY_LONG, {(long)0L}, (char *)0, 20, 0}, /* 8 BL_SCORE */
{ 0L, ANY_LONG, {(long)0L}, (char *)0, 20, 0}, /* 9 BL_CAP */
{ 0L, ANY_LONG, {(long)0L}, (char *)0, 10, 0}, /* 10 BL_GOLD */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, BL_ENEMAX}, /* 11 BL_ENE */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 12 BL_ENEMAX */
{ 0L, ANY_LONG, {(long)0L}, (char *)0, 10, 0}, /* 13 BL_XP */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 14 BL_AC */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 15 BL_HD */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 20, 0}, /* 16 BL_TIME */
{ 0L, ANY_UINT, {(long)0L}, (char *)0, 40, 0}, /* 17 BL_HUNGER */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, BL_HPMAX}, /* 18 BL_HP */
{ 0L, ANY_INT, {(long)0L}, (char *)0, 10, 0}, /* 19 BL_HPMAX */
{ 0L, ANY_STR, {(long)0L}, (char *)0, 80, 0}, /* 20 BL_LEVELDESC */
{ 0L, ANY_LONG, {(long)0L}, (char *)0, 20, 0}, /* 21 BL_EXP */
{ 0L, ANY_MASK32,{(long)0L},(char *)0, 0, 0} /* 22 BL_CONDITION */
{ 0L, ANY_STR, {(genericptr_t)0L}, (char *)0, 80, 0 }, /* 0 BL_TITLE */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 1 BL_STR */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 2 BL_DX */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 3 BL_CO */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 4 BL_IN */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 5 BL_WI */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 6 BL_CH */
{ 0L, ANY_STR, {(genericptr_t)0L}, (char *)0, 40, 0}, /* 7 BL_ALIGN */
{ 0L, ANY_LONG, {(genericptr_t)0L}, (char *)0, 20, 0}, /* 8 BL_SCORE */
{ 0L, ANY_LONG, {(genericptr_t)0L}, (char *)0, 20, 0}, /* 9 BL_CAP */
{ 0L, ANY_LONG, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 10 BL_GOLD */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, BL_ENEMAX}, /* 11 BL_ENE */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 12 BL_ENEMAX */
{ 0L, ANY_LONG, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 13 BL_XP */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 14 BL_AC */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 15 BL_HD */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 20, 0}, /* 16 BL_TIME */
{ 0L, ANY_UINT, {(genericptr_t)0L}, (char *)0, 40, 0}, /* 17 BL_HUNGER */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, BL_HPMAX}, /* 18 BL_HP */
{ 0L, ANY_INT, {(genericptr_t)0L}, (char *)0, 10, 0}, /* 19 BL_HPMAX */
{ 0L, ANY_STR, {(genericptr_t)0L}, (char *)0, 80, 0}, /* 20 BL_LEVELDESC */
{ 0L, ANY_LONG, {(genericptr_t)0L}, (char *)0, 20, 0}, /* 21 BL_EXP */
{ 0L, ANY_MASK32,{(genericptr_t)0L},(char *)0, 0, 0} /* 22 BL_CONDITION */
}
};

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)cmd.c 3.5 2006/04/14 */
/* SCCS Id: @(#)cmd.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -170,14 +170,14 @@ STATIC_DCL char *NDECL(parse);
STATIC_DCL boolean FDECL(help_dir, (CHAR_P,const char *));
STATIC_PTR int
doprev_message()
doprev_message(VOID_ARGS)
{
return nh_doprev_message();
}
/* Count down by decrementing multi */
STATIC_PTR int
timed_occupation()
timed_occupation(VOID_ARGS)
{
(*timed_occ_fn)();
if (multi > 0)
@@ -291,7 +291,7 @@ char ch;
#endif /* REDO */
STATIC_PTR int
doextcmd() /* here after # - now read a full-word command */
doextcmd(VOID_ARGS) /* here after # - now read a full-word command */
{
int idx, retval;
@@ -307,7 +307,7 @@ doextcmd() /* here after # - now read a full-word command */
}
int
doextlist() /* here after #? - now list all full-word commands */
doextlist(VOID_ARGS) /* here after #? - now list all full-word commands */
{
register const struct ext_func_tab *efp;
char buf[BUFSZ];
@@ -453,7 +453,7 @@ extcmd_via_menu() /* here after # - now show pick-list of possible commands */
/* #monster command - use special monster ability while polymorphed */
STATIC_PTR int
domonability()
domonability(VOID_ARGS)
{
if (can_breathe(youmonst.data)) return dobreathe();
else if (attacktype(youmonst.data, AT_SPIT)) return dospit();
@@ -484,7 +484,7 @@ domonability()
}
STATIC_PTR int
enter_explore_mode()
enter_explore_mode(VOID_ARGS)
{
if(!discover && !wizard) {
pline("Beware! From explore mode there will be no return to normal game.");
@@ -503,7 +503,7 @@ enter_explore_mode()
#ifdef DUNGEON_OVERVIEW
STATIC_PTR int
dooverview_or_wiz_where()
dooverview_or_wiz_where(VOID_ARGS)
{
#ifdef WIZARD
if (wizard) return wiz_where();
@@ -518,7 +518,7 @@ dooverview_or_wiz_where()
/* ^W command - wish for something */
STATIC_PTR int
wiz_wish() /* Unlimited wishes for debug mode by Paul Polderman */
wiz_wish(VOID_ARGS) /* Unlimited wishes for debug mode by Paul Polderman */
{
if (wizard) {
boolean save_verbose = flags.verbose;
@@ -535,7 +535,7 @@ wiz_wish() /* Unlimited wishes for debug mode by Paul Polderman */
/* ^I command - reveal and optionally identify hero's inventory */
STATIC_PTR int
wiz_identify()
wiz_identify(VOID_ARGS)
{
if (wizard) {
iflags.override_ID = (int)cmd_from_func(wiz_identify);
@@ -549,7 +549,7 @@ wiz_identify()
/* ^F command - reveal the level map and any traps on it */
STATIC_PTR int
wiz_map()
wiz_map(VOID_ARGS)
{
if (wizard) {
struct trap *t;
@@ -572,7 +572,7 @@ wiz_map()
/* ^G command - generate monster(s); a count prefix will be honored */
STATIC_PTR int
wiz_genesis()
wiz_genesis(VOID_ARGS)
{
if (wizard) (void) create_particular();
else pline("Unavailable command '%s'.",
@@ -582,7 +582,7 @@ wiz_genesis()
/* ^O command - display dungeon layout */
STATIC_PTR int
wiz_where()
wiz_where(VOID_ARGS)
{
if (wizard) (void) print_dungeon(FALSE, (schar *)0, (xchar *)0);
else pline("Unavailable command '%s'.",
@@ -592,7 +592,7 @@ wiz_where()
/* ^E command - detect unseen (secret doors, traps, hidden monsters) */
STATIC_PTR int
wiz_detect()
wiz_detect(VOID_ARGS)
{
if(wizard) (void) findit();
else pline("Unavailable command '%s'.",
@@ -602,7 +602,7 @@ wiz_detect()
/* ^V command - level teleport */
STATIC_PTR int
wiz_level_tele()
wiz_level_tele(VOID_ARGS)
{
if (wizard) level_tele();
else pline("Unavailable command '%s'.",
@@ -612,7 +612,7 @@ wiz_level_tele()
/* #monpolycontrol command - choose new form for shapechangers, polymorphees */
STATIC_PTR int
wiz_mon_polycontrol()
wiz_mon_polycontrol(VOID_ARGS)
{
iflags.mon_polycontrol = !iflags.mon_polycontrol;
pline("Monster polymorph control is %s.",
@@ -622,7 +622,7 @@ wiz_mon_polycontrol()
/* #levelchange command - adjust hero's experience level */
STATIC_PTR int
wiz_level_change()
wiz_level_change(VOID_ARGS)
{
char buf[BUFSZ];
int newlevel;
@@ -662,7 +662,7 @@ wiz_level_change()
/* #panic command - test program's panic handling */
STATIC_PTR int
wiz_panic()
wiz_panic(VOID_ARGS)
{
if (yn("Do you want to call panic() and end your game?") == 'y')
panic("crash test.");
@@ -671,7 +671,7 @@ wiz_panic()
/* #polyself command - change hero's form */
STATIC_PTR int
wiz_polyself()
wiz_polyself(VOID_ARGS)
{
polyself(1);
return 0;
@@ -679,7 +679,7 @@ wiz_polyself()
/* #seenv command */
STATIC_PTR int
wiz_show_seenv()
wiz_show_seenv(VOID_ARGS)
{
winid win;
int x, y, v, startx, stopx, curx;
@@ -721,7 +721,7 @@ wiz_show_seenv()
/* #vision command */
STATIC_PTR int
wiz_show_vision()
wiz_show_vision(VOID_ARGS)
{
winid win;
int x, y, v;
@@ -758,7 +758,7 @@ wiz_show_vision()
/* #wmode command */
STATIC_PTR int
wiz_show_wmodes()
wiz_show_wmodes(VOID_ARGS)
{
winid win;
int x,y;
@@ -793,7 +793,7 @@ wiz_show_wmodes()
/* #terrain command */
STATIC_PTR int
wiz_map_terrain()
wiz_map_terrain(VOID_ARGS)
{
winid win;
int x, y, terrain;
@@ -899,7 +899,7 @@ wiz_map_terrain()
/* #wizsmell command - test usmellmon(). */
STATIC_PTR int
wiz_smell()
wiz_smell(VOID_ARGS)
{
char out_str[BUFSZ];
struct permonst *pm = 0;
@@ -946,7 +946,7 @@ wiz_smell()
/* #wizrumorcheck command - verify each rumor access */
STATIC_PTR int
wiz_rumor_check()
wiz_rumor_check(VOID_ARGS)
{
rumor_check();
return 0;
@@ -1463,7 +1463,7 @@ minimal_enlightenment()
/* ^X command */
STATIC_PTR int
doattributes()
doattributes(VOID_ARGS)
{
if (!minimal_enlightenment())
return 0;
@@ -1476,7 +1476,7 @@ doattributes()
* (shares enlightenment's tense handling)
*/
STATIC_PTR int
doconduct()
doconduct(VOID_ARGS)
{
show_conduct(0);
return 0;
@@ -2865,7 +2865,7 @@ readchar()
}
STATIC_PTR int
dotravel()
dotravel(VOID_ARGS)
{
/* Keyboard travel command */
static char cmd[2];

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)dig.c 3.5 2005/11/19 */
/* SCCS Id: @(#)dig.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -207,7 +207,7 @@ dig_check(madeby, verbose, x, y)
}
STATIC_OVL int
dig()
dig(VOID_ARGS)
{
register struct rm *lev;
register xchar dpx = context.digging.pos.x, dpy = context.digging.pos.y;

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)dlb.c 3.5 1997/07/29 */
/* SCCS Id: @(#)dlb.c 3.5 2006/06/25 */
/* Copyright (c) Kenneth Lorber, Bethesda, Maryland, 1993. */
/* NetHack may be freely redistributed. See license for details. */
@@ -237,7 +237,7 @@ close_library(lp)
* keep track of the file position.
*/
STATIC_OVL boolean
lib_dlb_init()
lib_dlb_init(VOID_ARGS)
{
/* zero out array */
(void) memset((char *)&dlb_libs[0], 0, sizeof(dlb_libs));
@@ -254,7 +254,7 @@ lib_dlb_init()
}
STATIC_OVL void
lib_dlb_cleanup()
lib_dlb_cleanup(VOID_ARGS)
{
int i;

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)do.c 3.5 2006/05/08 */
/* SCCS Id: @(#)do.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -1606,7 +1606,7 @@ donull()
}
STATIC_PTR int
wipeoff()
wipeoff(VOID_ARGS)
{
if(u.ucreamed < 4) u.ucreamed = 0;
else u.ucreamed -= 4;

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)do_wear.c 3.5 2006/05/17 */
/* SCCS Id: @(#)do_wear.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -32,7 +32,7 @@ static NEARDATA const long takeoff_order[] = { WORN_BLINDF, W_WEP,
STATIC_DCL void FDECL(on_msg, (struct obj *));
STATIC_PTR int NDECL(Armor_on);
STATIC_PTR int NDECL(Boots_on);
STATIC_DCL int NDECL(Cloak_on);
STATIC_PTR int NDECL(Cloak_on);
STATIC_PTR int NDECL(Helmet_on);
STATIC_PTR int NDECL(Gloves_on);
STATIC_DCL void FDECL(wielding_corpse, (struct obj *,BOOLEAN_P));
@@ -84,7 +84,7 @@ struct obj *otmp;
STATIC_PTR
int
Boots_on()
Boots_on(VOID_ARGS)
{
long oldprop =
u.uprops[objects[uarmf->otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
@@ -136,7 +136,7 @@ Boots_on()
}
int
Boots_off()
Boots_off(VOID_ARGS)
{
int otyp = uarmf->otyp;
long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_BOOTS;
@@ -195,8 +195,8 @@ Boots_off()
return 0;
}
STATIC_OVL int
Cloak_on()
STATIC_PTR int
Cloak_on(VOID_ARGS)
{
long oldprop =
u.uprops[objects[uarmc->otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
@@ -245,7 +245,7 @@ Cloak_on()
}
int
Cloak_off()
Cloak_off(VOID_ARGS)
{
int otyp = uarmc->otyp;
long oldprop = u.uprops[objects[otyp].oc_oprop].extrinsic & ~WORN_CLOAK;
@@ -292,7 +292,7 @@ Cloak_off()
STATIC_PTR
int
Helmet_on()
Helmet_on(VOID_ARGS)
{
switch(uarmh->otyp) {
case FEDORA:
@@ -349,7 +349,7 @@ Helmet_on()
}
int
Helmet_off()
Helmet_off(VOID_ARGS)
{
context.takeoff.mask &= ~W_ARMH;
@@ -392,7 +392,7 @@ Helmet_off()
STATIC_PTR
int
Gloves_on()
Gloves_on(VOID_ARGS)
{
long oldprop =
u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
@@ -440,7 +440,7 @@ boolean voluntary; /* taking gloves off on purpose? */
}
int
Gloves_off()
Gloves_off(VOID_ARGS)
{
long oldprop =
u.uprops[objects[uarmg->otyp].oc_oprop].extrinsic & ~WORN_GLOVES;
@@ -481,8 +481,8 @@ Gloves_off()
return 0;
}
STATIC_OVL int
Shield_on()
STATIC_PTR int
Shield_on(VOID_ARGS)
{
/*
switch (uarms->otyp) {
@@ -501,7 +501,7 @@ Shield_on()
}
int
Shield_off()
Shield_off(VOID_ARGS)
{
context.takeoff.mask &= ~W_ARMS;
/*
@@ -522,8 +522,8 @@ Shield_off()
}
#ifdef TOURIST
STATIC_OVL int
Shirt_on()
STATIC_PTR int
Shirt_on(VOID_ARGS)
{
/*
switch (uarmu->otyp) {
@@ -537,7 +537,7 @@ Shirt_on()
}
int
Shirt_off()
Shirt_off(VOID_ARGS)
{
context.takeoff.mask &= ~W_ARMU;
/*
@@ -559,13 +559,13 @@ Shirt_off()
*/
STATIC_PTR
int
Armor_on()
Armor_on(VOID_ARGS)
{
return 0;
}
int
Armor_off()
Armor_off(VOID_ARGS)
{
context.takeoff.mask &= ~W_ARM;
setworn((struct obj *)0, W_ARM);
@@ -1966,7 +1966,7 @@ do_takeoff()
/* occupation callback for 'A' */
STATIC_PTR
int
take_off()
take_off(VOID_ARGS)
{
register int i;
register struct obj *otmp;

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)eat.c 3.5 2006/04/14 */
/* SCCS Id: @(#)eat.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -148,7 +148,7 @@ static char *eatmbuf = 0; /* set by cpostfx() */
STATIC_PTR
int
eatmdone() /* called after mimicing is over */
eatmdone(VOID_ARGS) /* called after mimicing is over */
{
/* release `eatmbuf' */
if (eatmbuf) {
@@ -363,7 +363,7 @@ do_reset_eat()
STATIC_PTR
int
eatfood() /* called each move during eating process */
eatfood(VOID_ARGS) /* called each move during eating process */
{
if(!context.victual.piece ||
(!carried(context.victual.piece) &&
@@ -1255,7 +1255,7 @@ boolean disp; /* we're just displaying so leave things alone */
STATIC_PTR
int
opentin() /* called during each move whilst opening a tin */
opentin(VOID_ARGS) /* called during each move whilst opening a tin */
{
register int r;
const char *what;
@@ -1437,7 +1437,7 @@ no_opener:
}
int
Hear_again() /* called when waking up after fainting */
Hear_again(VOID_ARGS) /* called when waking up after fainting */
{
/* Chance of deafness going away while fainted/sleepeing/etc. */
if (!rn2(2))
@@ -2550,7 +2550,7 @@ register int num;
STATIC_PTR
int
unfaint()
unfaint(VOID_ARGS)
{
(void) Hear_again();
if(u.uhs > FAINTING)

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)lock.c 3.5 2006/01/02 */
/* SCCS Id: @(#)lock.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -72,7 +72,7 @@ lock_action()
STATIC_PTR
int
picklock() /* try to open/close a lock */
picklock(VOID_ARGS) /* try to open/close a lock */
{
if (xlock.box) {
@@ -128,7 +128,7 @@ picklock() /* try to open/close a lock */
STATIC_PTR
int
forcelock() /* try to force a locked chest */
forcelock(VOID_ARGS) /* try to force a locked chest */
{
register struct obj *otmp;

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)spell.c 3.5 2006/05/17 */
/* SCCS Id: @(#)spell.c 3.5 2006/06/25 */
/* Copyright (c) M. Stephenson 1988 */
/* NetHack may be freely redistributed. See license for details. */
@@ -325,7 +325,7 @@ raise_dead:
}
STATIC_PTR int
learn()
learn(VOID_ARGS)
{
int i;
short booktype;

View File

@@ -1,4 +1,4 @@
/* SCCS Id: @(#)steal.c 3.5 2005/12/14 */
/* SCCS Id: @(#)steal.c 3.5 2006/06/25 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -179,7 +179,7 @@ unsigned int stealoid; /* object to be stolen */
unsigned int stealmid; /* monster doing the stealing */
STATIC_PTR int
stealarm()
stealarm(VOID_ARGS)
{
register struct monst *mtmp;
register struct obj *otmp;